XU XUv0.16.0

#compress/gzip

import: #compress/gzip

counts: 4 functions, 11 methods, 3 types, 5 constants, 0 method sets

gzip Reader/Writer with CRC-32.

const OS_FAT

XuAPI
pub const OS_FAT = 0

Purpose

RFC 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.

const OS_UNIX

XuAPI
pub const OS_UNIX = 3

Purpose

Constant OS_UNIX, defining protocol or algorithm parameters.

const OS_MACINTOSH

XuAPI
pub const OS_MACINTOSH = 7

Purpose

Constant OS_MACINTOSH, defining protocol or algorithm parameters.

const OS_NTFS

XuAPI
pub const OS_NTFS = 11

Purpose

Constant OS_NTFS, defining protocol or algorithm parameters.

const OS_UNKNOWN

XuAPI
pub const OS_UNKNOWN = 255

Purpose

Constant OS_UNKNOWN, defining protocol or algorithm parameters.

struct Reader

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

Purpose

Gzip Streaming reader and decoder.

Public fields

data string
data
sticky string
field (string)

struct Header

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

Purpose

Gzip Metadata header descriptor structure.

Public fields

mtime int
field (int)
name string
name
comment string
field (string)
os int
field (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
}

Purpose

Gzip Streaming writer and encoder.

Public fields

buf string
buffer
out string
field (string)
closed bool
field (bool)
name string
name
comment string
field (string)
mtime int
field (int)
os int
field (int)

host_os

XuAPI
pub fn host_os() int

Purpose

Host os.

Parameters

No arguments are required.

Returns

int — a value of this type

new_reader

XuAPI
pub fn new_reader(data string) Reader

Purpose

Construct reader.

Parameters

data string
data (string)

Returns

Reader — a value of this type

new_writer

XuAPI
pub fn new_writer() Writer

Purpose

Construct writer.

Parameters

No arguments are required.

Returns

Writer — a value of this type

($&Writer) set_name

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

Purpose

Operation on $&Writer: set name.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
n string
count, length, or limit (string)

Returns

This call does not return a value.

($&Writer) set_comment

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

Purpose

Operation on $&Writer: set comment.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
s string
source string (string)

Returns

This call does not return a value.

($&Writer) set_mtime

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

Purpose

Operation on $&Writer: set mtime.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
sec int
sec (int)

Returns

This call does not return a value.

($&Writer) set_os

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

Purpose

Operation on $&Writer: set os.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
id int
id (int)

Returns

This call does not return a value.

(&Reader) header

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

Purpose

Execute header on &Reader. Throws on failure; handle the error or propagate it to the caller.

Parameters

r &Reader
The Reader instance used by this call (borrow).

Returns

Header — a value of this type

($&Reader) read_all

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

Purpose

Operation on $&Reader: read all. Throws on failure; handle the error or propagate it to the caller.

Parameters

r $&Reader
The Reader instance used by this call (exclusive borrow).

Returns

string — result string

($&Writer) write

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

Purpose

Operation on $&Writer: write data and return the byte count. Throws on failure; handle the error or propagate it to the caller.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

($&Writer) write_string

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

Purpose

Operation on $&Writer: write a string and return the byte count.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).
s string
source string (string)

Returns

int — bytes written

($&Writer) close

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

Purpose

Operation on $&Writer: close the resource.

Parameters

w $&Writer
The Writer instance used by this call (exclusive borrow).

Returns

int — a value of this type

(&Writer) bytes

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

Purpose

Operation on &Writer: return the buffered bytes.

Parameters

w &Writer
The Writer instance used by this call (borrow).

Returns

string — result string

(&Writer) text

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

Purpose

Operation on &Writer: return the current text.

Parameters

w &Writer
The Writer instance used by this call (borrow).

Returns

string — result string

copy_stream

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

Purpose

Emit 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; handle the error or propagate it to the caller.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)

Returns

int — a value of this type