struct Reader
pub struct Reader {
pub data string
pub sticky string
}Purpose
Public struct `Reader`.
Parameters
datastring- data
stickystring- field (string)
API
#compress/gzipgzip Reader/Writer with CRC-32.
struct Readerpub struct Reader {
pub data string
pub sticky string
}Public struct `Reader`.
data stringsticky stringstruct Headerpub struct Header {
pub mtime int
pub name string
pub comment string
pub os int
}Public struct `Header`.
mtime intname stringcomment stringos intstruct Writerpub struct Writer {
pub buf string
pub out string
pub closed bool
pub name string
pub comment string
pub mtime int
pub os int
}Public struct `Writer`.
buf stringout stringclosed boolname stringcomment stringmtime intos intconst os_fatpub const os_fat = 0RFC 1952 OS byte. host_os maps xu_target_os: Windows FAT/Win32=0, macOS/Linux Unix=3, other=255. gzip writes 255 by default; Xu records the compile target so archives are platform-honest. Value `0`.
none
const os_unixpub const os_unix = 3Public constant `os_unix`. Value `3`.
none
const os_macintoshpub const os_macintosh = 7Public constant `os_macintosh`. Value `7`.
none
const os_ntfspub const os_ntfs = 11Public constant `os_ntfs`. Value `11`.
none
const os_unknownpub const os_unknown = 255Public constant `os_unknown`. Value `255`.
none
host_ospub fn host_os() intHost os.
none
int — a value of this type
new_readerpub fn new_reader(data string) ReaderConstruct reader.
data stringReader — a value of this type
new_writerpub fn new_writer() WriterConstruct writer.
none
Writer — a value of this type
(&mut Writer) set_namepub fn (w &mut Writer) set_name(n string)Method on `&mut Writer`: set name.
w &mut Writern string(&mut Writer) set_commentpub fn (w &mut Writer) set_comment(s string)Method on `&mut Writer`: set comment.
w &mut Writers string(&mut Writer) set_mtimepub fn (w &mut Writer) set_mtime(sec int)Method on `&mut Writer`: set mtime.
w &mut Writersec int(&mut Writer) set_ospub fn (w &mut Writer) set_os(id int)Method on `&mut Writer`: set os.
w &mut Writerid int(&Reader) headerpub fn (r &Reader) header() HeaderCall `header` on `&Reader`. Throws on failure.
r &ReaderHeader — a value of this type
(&mut Reader) read_allpub fn (r &mut Reader) read_all() stringMethod on `&mut Reader`: read all. Throws on failure.
r &mut Readerstring — result string
(&mut Writer) writepub fn (w &mut Writer) write(data &string) intMethod on `&mut Writer`: write data and return the byte count. Throws on failure.
w &mut Writerdata &stringint — bytes written
(&mut Writer) write_stringpub fn (w &mut Writer) write_string(s string) intMethod on `&mut Writer`: write a string and return the byte count.
w &mut Writers stringint — bytes written
(&mut Writer) closepub fn (w &mut Writer) close() intMethod on `&mut Writer`: close the resource.
w &mut Writerint — a value of this type
(&Writer) bytespub fn (w &Writer) bytes() stringMethod on `&Writer`: return the buffered bytes.
w &Writerstring — result string
(&Writer) textpub fn (w &Writer) text() stringMethod on `&Writer`: return the current text.
w &Writerstring — result string
copy_streampub fn copy_stream#W:StreamWriter,R:StreamReader(dst &mut W, src &mut R) intEmit a gzip member directly to dst using legal non-final stored deflate blocks, then an empty final block and CRC32/ISIZE trailer. No input or output is accumulated. Returns the uncompressed byte count and closes neither endpoint. Failed copies leave an incomplete member; discard it, don't retry. Throws on failure.
dst &mut Wsrc &mut Rint — a value of this type