XU XUv0.8.8
EN

API

#compress/gzip

import: #compress/gzip

counts: 4 函数, 11 方法, 3 类型, 5 常量, 0 方法集

gzip Reader/Writer,校验 CRC-32。

struct Reader

XuAPI
pub struct Reader {
    pub data string
    pub sticky string
}

用途

公开结构体 `Reader`。

参数

data string
数据
sticky string
字段(string)

struct Header

XuAPI
pub struct Header {
    pub mtime int
    pub name string
    pub comment string
    pub os int
}

用途

公开结构体 `Header`。

参数

mtime int
字段(int)
name string
名字
comment string
字段(string)
os int
字段(int)

struct Writer

XuAPI
pub struct Writer {
    pub buf string
    pub out string
    pub closed bool
    pub name string
    pub comment string
    pub mtime int
    pub os int
}

用途

公开结构体 `Writer`。

参数

buf string
缓冲
out string
字段(string)
closed bool
字段(bool)
name string
名字
comment string
字段(string)
mtime int
字段(int)
os int
字段(int)

const os_fat

XuAPI
pub const os_fat = 0

用途

公开常量 `os_fat`。 值为 `0`

参数

无

const os_unix

XuAPI
pub const os_unix = 3

用途

公开常量 `os_unix`。 值为 `3`

参数

无

const os_macintosh

XuAPI
pub const os_macintosh = 7

用途

公开常量 `os_macintosh`。 值为 `7`

参数

无

const os_ntfs

XuAPI
pub const os_ntfs = 11

用途

公开常量 `os_ntfs`。 值为 `11`

参数

无

const os_unknown

XuAPI
pub const os_unknown = 255

用途

公开常量 `os_unknown`。 值为 `255`

参数

无

host_os

XuAPI
pub fn host_os() int

用途

主机os。

参数

无

返回

int — 该类型的值

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 — 该类型的值

(&mut Writer) set_name

XuAPI
pub fn (w &mut Writer) set_name(n string)

用途

`&mut Writer` 上的方法:设置 name。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
n string
数量、长度或上限(string)

(&mut Writer) set_comment

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

用途

`&mut Writer` 上的方法:设置 comment。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
s string
源字符串(string)

(&mut Writer) set_mtime

XuAPI
pub fn (w &mut Writer) set_mtime(sec int)

用途

`&mut Writer` 上的方法:设置 mtime。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
sec int
sec(int)

(&mut Writer) set_os

XuAPI
pub fn (w &mut Writer) set_os(id int)

用途

`&mut Writer` 上的方法:设置 os。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
id int
id(int)

(&Reader) header

XuAPI
pub fn (r &Reader) header() Header

用途

`&Reader` 上的方法:头。失败时 throw。

参数

r &Reader
接收者 &Reader(借用)

返回

Header — 该类型的值

(&mut Reader) read_all

XuAPI
pub fn (r &mut Reader) read_all() string

用途

`&mut Reader` 上的方法:读取all。失败时 throw。

参数

r &mut Reader
接收者 &mut Reader(可变借用)

返回

string — 结果字符串

(&mut Writer) write

XuAPI
pub fn (w &mut Writer) write(data &string) int

用途

`&mut Writer` 上的方法:写入数据,返回写入的字节数。失败时 throw。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
data &string
数据(借用,调用方仍持有;类型 &string)

返回

int — 写入的字节数

(&mut Writer) write_string

XuAPI
pub fn (w &mut Writer) write_string(s string) int

用途

`&mut Writer` 上的方法:写入字符串,返回写入的字节数。

参数

w &mut Writer
接收者 &mut Writer(可变借用)
s string
源字符串(string)

返回

int — 写入的字节数

(&mut Writer) close

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

用途

`&mut Writer` 上的方法:关闭资源。

参数

w &mut Writer
接收者 &mut Writer(可变借用)

返回

int — 该类型的值

(&Writer) bytes

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

用途

`&Writer` 上的方法:返回已缓冲的字节串。

参数

w &Writer
接收者 &Writer(借用)

返回

string — 结果字符串

(&Writer) text

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

用途

`&Writer` 上的方法:返回当前文本。

参数

w &Writer
接收者 &Writer(借用)

返回

string — 结果字符串

copy_stream

XuAPI
pub fn copy_stream#W:StreamWriter,R:StreamReader(dst &mut W, src &mut R) int

用途

拷贝流。失败时 throw。

参数

dst &mut W
目标(独占借用;类型 &mut W)
src &mut R
源数据(独占借用;类型 &mut R)

返回

int — 该类型的值