XU XUv0.16.0

#archive/zip

导入方式: #archive/zip

公开 API: 3 函数, 7 方法, 3 类型, 2 常量, 0 方法集

zip Reader/Writer(Store 与 deflate)。无 ZIP64。

const STORE

XuAPI
pub const STORE = 0

用途

常量 STORE,定义了相关的协议或算法配置参数。

const DEFLATE

XuAPI
pub const DEFLATE = 8

用途

常量 DEFLATE,定义了相关的协议或算法配置参数。

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
}

用途

承载 name、method、crc32、compressed_size、uncompressed_size 等属性的结构体。

公开字段

name string
名字
method int
字段(int)
crc32 int
字段(int)
compressed_size int
字段(int)
uncompressed_size int
字段(int)
body string
正文

struct Reader

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

用途

Zip 流式数据读取与解码器。

公开字段

data string
数据
pos int
字段(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
}

用途

Zip 流式数据写入与序列化器。

公开字段

buf string
缓冲
names []string
字段([]string)
methods []int
字段([]int)
crcs []int
字段([]int)
comps []int
字段([]int)
uncomps []int
字段([]int)
offsets []int
字段([]int)
closed int
字段(int)
comment string
字段(string)

new_reader

XuAPI
pub fn new_reader(data &string) Reader

用途

构造 reader。

参数

data &string
数据(只读借用,调用方仍持有原值;类型 &string)

返回值

Reader — 该类型的值

new_writer

XuAPI
pub fn new_writer() Writer

用途

构造 writer。

参数

无需传入参数。

返回值

Writer — 该类型的值

($&Writer) set_comment

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

用途

$&Writer 上的操作:设置 comment。

参数

w $&Writer
本次调用使用的 Writer 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
s string
源字符串(string)

返回值

不返回值。

(&Writer) file_count

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

用途

&Writer 上的操作:文件计数。

参数

w &Writer
本次调用使用的 Writer 实例;以只读借用传入,调用方仍持有实例。

返回值

int — 该类型的值

comment

XuAPI
pub fn comment(data &string) string

用途

执行 comment 处理。失败时抛出错误,调用方需处理或继续传播。

参数

data &string
数据(只读借用,调用方仍持有原值;类型 &string)

返回值

string — 结果字符串

(&Writer) bytes

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

用途

&Writer 上的操作:返回已缓冲的字节串。

参数

w &Writer
本次调用使用的 Writer 实例;以只读借用传入,调用方仍持有实例。

返回值

string — 结果字符串

($&Writer) write_file

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

用途

$&Writer 上的操作:写入文件。

参数

w $&Writer
本次调用使用的 Writer 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
name &string
名字(只读借用,调用方仍持有原值;类型 &string)
body &string
正文(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

($&Writer) write_file_deflate

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

用途

$&Writer 上的操作:写入文件压缩。

参数

w $&Writer
本次调用使用的 Writer 实例;以独占借用传入,方法可修改它,调用方仍持有实例。
name &string
名字(只读借用,调用方仍持有原值;类型 &string)
body &string
正文(只读借用,调用方仍持有原值;类型 &string)

返回值

int — 该类型的值

($&Writer) close

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

用途

$&Writer 上的操作:关闭资源。失败时抛出错误,调用方需处理或继续传播。

参数

w $&Writer
本次调用使用的 Writer 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

int — 该类型的值

($&Reader) next

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

用途

$&Reader 上的操作:取出下一项;没有则按本类型约定结束。失败时抛出错误,调用方需处理或继续传播。

参数

r $&Reader
本次调用使用的 Reader 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

File — 该类型的值