API referencestd/compress

std/compress/io

Public declarations, types, methods, and source contracts for std/compress/io.

On this page

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/io"

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
deflate std/compress/deflate io.dodo
mem core/mem io.dodo
streamio std/io io.dodo

Decoder

Interface · Source

Adapters between std/io streams and the incremental codecs. deflate, zlib, and gzip Decoder and Encoder values all satisfy these interfaces.

pub interface Decoder {
    fn process(&mut self, input: &[u8], output: &mut[u8]) -> deflate.Progress!deflate.Error
    fn reset(&mut self)
}

Encoder

Interface · Source

pub interface Encoder {
    fn process(&mut self, input: &[u8], output: &mut[u8], finish: bool) -> deflate.Progress
}

ErrorKind

Enum · Source

read_checked keeps device failures apart from format errors.

pub enum ErrorKind {
    // The source failed; cause holds its error.
    Io,
    // The source ended inside the stream.
    Truncated,
    // The stream is malformed; format holds the decoder's error.
    Format
}

Error

Struct · Source

pub struct Error {
    pub kind: ErrorKind
    pub format: deflate.Error
    pub transferred: usize
    pub cause: streamio.Error
}

Reader

Struct · Source

Decompresses one stream from source. Compressed bytes are read into the caller’s storage; bytes read past the end of the stream stay available through buffered(). A one-byte storage never reads past the stream.

pub struct Reader<R: streamio.Reader, D: Decoder> {
    // Private implementation fields omitted.
}

Reader.new

Function · Source

pub fn new(source: &mut R, decoder: &mut D, storage: &mut[u8]) -> Reader<R, D>!streamio.Error from(source, decoder, storage)

Reader.buffered

Function · Source

Source bytes read but not consumed by the decoder.

pub fn buffered(&self) -> &[u8]

Reader.is_done

Function · Source

pub fn is_done(&self) -> bool

Reader.next_stream

Function · Source

Resets the decoder to read a following stream, such as the next member of a concatenated gzip file. Returns false at the end of the source.

pub fn next_stream(&mut self) -> bool!Error

Reader.read_checked

Function · Source

pub fn read_checked(&mut self, output: &mut[u8]) -> usize!Error

Reader.read

Function · Source

std/io Reader compatibility. Format errors become InvalidInput and truncation UnexpectedEof; use read_checked to tell them apart.

pub fn read(&mut self, output: &mut[u8]) -> usize!streamio.Error

Writer

Struct · Source

Compresses everything written into one stream on sink. Call finish() and handle its result to write the final block and trailer. After a sink error the unwritten compressed bytes are kept for the next write or finish.

pub struct Writer<W: streamio.Writer, E: Encoder> {
    // Private implementation fields omitted.
}

Writer.new

Function · Source

pub fn new(sink: &mut W, encoder: &mut E) -> Writer<W, E> from(sink, encoder)

Writer.write

Function · Source

Accepts all of input unless the sink fails; the error then counts the input accepted.

pub fn write(&mut self, input: &[u8]) -> usize!streamio.Error

Writer.finish

Function · Source

Ends the stream. Repeatable after a sink error; returns the compressed byte count written by this call.

pub fn finish(&mut self) -> usize!streamio.Error

Search every guide, reference page, and API declaration.