Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/compress/gzip"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
checksum |
std/checksum |
gzip.dodo |
deflate |
std/compress/deflate |
gzip.dodo |
max_encoded_len
Function · Source
An output length that every encode level is guaranteed to fit.
pub fn max_encoded_len(input_len: usize) -> usize
Header
Struct · Source
Member metadata. Fields are byte strings without terminating zeros; RFC 1952 specifies ISO 8859-1 for name and comment. Empty fields are absent.
pub struct Header {
// Modification time in seconds since 1970, or 0 when unknown.
pub mtime: u32
// Operating system that wrote the member: 3 is Unix, 255 unknown.
pub os: u8
// Whether the data is probably text.
pub text: bool
pub extra: &[u8]
pub name: &[u8]
pub comment: &[u8]
}
HeaderInfo
Struct · Source
pub struct HeaderInfo {
pub header: Header
// Header bytes, where the compressed data starts.
pub length: usize
}
read_header
Function · Source
Parses and validates the header at the start of input, including its CRC when present. Truncated means the header continues past input.
pub fn read_header(input: &[u8]) -> HeaderInfo!deflate.Error from(input)
header_len
Function · Source
Bytes encode_with_header spends on this header, or InvalidArgument for an extra field over 65535 bytes or a name or comment containing a zero byte.
pub fn header_len(header: &Header) -> usize!deflate.Error
decode
Function · Source
Decodes one gzip member; a following member or other data is left unconsumed, so call again on the suffix for concatenated members. On error the output contents are unspecified.
pub fn decode(input: &[u8], output: &mut[u8]) -> deflate.DecodeResult!deflate.Error
encode
Function · Source
Compresses input into one gzip member at level 0 through 9; see deflate.encode. max_encoded_len(input.len) bytes always suffice.
pub fn encode(input: &[u8], output: &mut[u8], level: usize) -> usize!deflate.Error
encode_with_workspace
Function · Source
pub fn encode_with_workspace(input: &[u8], output: &mut[u8], level: usize, words: &mut[u32]) -> usize!deflate.Error
encode_with_header
Function · Source
Like encode_with_workspace, writing header’s metadata. Output needs up to header_len(header) - 10 bytes beyond max_encoded_len(input.len).
pub fn encode_with_header(input: &[u8], output: &mut[u8], level: usize, header: &Header, words: &mut[u32]) -> usize!deflate.Error
Decoder
Struct · Source
Incremental decoder for one gzip member. Optional header fields are skipped without buffering. It reads nothing past the trailer, so a following member stays in the input; reset() prepares for it. Errors are final.
pub struct Decoder {
// Private implementation fields omitted.
}
Decoder.new
Function · Source
pub fn new() -> Decoder
Decoder.reset
Function · Source
pub fn reset(&mut self)
Decoder.is_done
Function · Source
pub fn is_done(&self) -> bool
Decoder.process
Function · Source
pub fn process(&mut self, input: &[u8], output: &mut[u8]) -> deflate.Progress!deflate.Error
Encoder
Struct · Source
Incremental gzip compressor; see deflate.Encoder for the process contract.
pub struct Encoder {
// Private implementation fields omitted.
}
Encoder.new
Function · Source
Borrows storage as deflate.Encoder.new does.
pub fn new(level: usize, buffer: &mut[u8], words: &mut[u32]) -> Encoder!deflate.Error from(buffer, words)
Encoder.reset
Function · Source
pub fn reset(&mut self)
Encoder.process
Function · Source
pub fn process(&mut self, input: &[u8], output: &mut[u8], finish: bool) -> deflate.Progress