XU XUv0.8.8
中文

API

#archive/zip

import: #archive/zip

counts: 3 fns, 7 methods, 3 types, 2 consts, 0 ifaces

zip Reader/Writer (Store and deflate). No ZIP64.

const store

XuAPI
pub const store = 0

Purpose

ZIP subset aligned with `archive/zip` Reader/Writer common path. Archives are owning strings (no io.Reader). Writer emits Store or deflate (via compress.flate). Reader inflates method 8. No ZIP64, data descriptor, encryption, or disk spanning. Value `0`.

Parameters

none

const deflate

XuAPI
pub const deflate = 8

Purpose

Public constant `deflate`. Value `8`.

Parameters

none

struct File

XuAPI
pub struct File {
    pub name string
    pub method int
    pub crc32 int
    pub compressed_size int
    pub uncompressed_size int
    pub body string
}

Purpose

Public struct `File`.

Parameters

name string
name
method int
field (int)
crc32 int
field (int)
compressed_size int
field (int)
uncompressed_size int
field (int)
body string
body

struct Reader

XuAPI
pub struct Reader {
    pub data string
    pub pos int
}

Purpose

Public struct `Reader`.

Parameters

data string
data
pos int
field (int)

struct Writer

XuAPI
pub struct Writer {
    pub buf string
    pub names []string
    pub methods []int
    pub crcs []int
    pub comps []int
    pub uncomps []int
    pub offsets []int
    pub closed int
    pub comment string
}

Purpose

Public struct `Writer`.

Parameters

buf string
buffer
names []string
field ([]string)
methods []int
field ([]int)
crcs []int
field ([]int)
comps []int
field ([]int)
uncomps []int
field ([]int)
offsets []int
field ([]int)
closed int
field (int)
comment string
field (string)

new_reader

XuAPI
pub fn new_reader(data &string) Reader

Purpose

Construct reader.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

Reader — a value of this type

new_writer

XuAPI
pub fn new_writer() Writer

Purpose

Construct writer.

Parameters

none

Returns

Writer — a value of this type

(&mut Writer) set_comment

XuAPI
pub fn (w &mut Writer) set_comment(s string)

Purpose

Method on `&mut Writer`: set comment.

Parameters

w &mut Writer
receiver &mut Writer (exclusive borrow)
s string
source string (string)

(&Writer) file_count

XuAPI
pub fn (w &Writer) file_count() int

Purpose

Method on `&Writer`: file count.

Parameters

w &Writer
receiver &Writer (borrow)

Returns

int — a value of this type

comment

XuAPI
pub fn comment(data &string) string

Purpose

comment; returns string. Throws on failure.

Parameters

data &string
data (borrowed; caller keeps it; type &string)

Returns

string — result string

(&Writer) bytes

XuAPI
pub fn (w &Writer) bytes() string

Purpose

Method on `&Writer`: return the buffered bytes.

Parameters

w &Writer
receiver &Writer (borrow)

Returns

string — result string

(&mut Writer) write_file

XuAPI
pub fn (w &mut Writer) write_file(name &string, body &string) int

Purpose

Method on `&mut Writer`: write file.

Parameters

w &mut Writer
receiver &mut Writer (exclusive borrow)
name &string
name (borrowed; caller keeps it; type &string)
body &string
body (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

(&mut Writer) write_file_deflate

XuAPI
pub fn (w &mut Writer) write_file_deflate(name &string, body &string) int

Purpose

Method on `&mut Writer`: write file deflate.

Parameters

w &mut Writer
receiver &mut Writer (exclusive borrow)
name &string
name (borrowed; caller keeps it; type &string)
body &string
body (borrowed; caller keeps it; type &string)

Returns

int — a value of this type

(&mut Writer) close

XuAPI
pub fn (w &mut Writer) close() int

Purpose

Method on `&mut Writer`: close the resource. Throws on failure.

Parameters

w &mut Writer
receiver &mut Writer (exclusive borrow)

Returns

int — a value of this type

(&mut Reader) next

XuAPI
pub fn (r &mut Reader) next() File

Purpose

Method on `&mut Reader`: take the next item, or end according to this type. Throws on failure.

Parameters

r &mut Reader
receiver &mut Reader (exclusive borrow)

Returns

File — a value of this type