Compression decoders read from one input stream (an
src) and write to an output stream (an
dst). Wuffs' implementations have one key method:
transform_io. It incrementally decompresses the source data.
This method is a coroutine, and does not require either all of the input or all of the output to fit in a single contiguous buffer. It can suspend with the
$short_write statuses when the
src buffer needs re-filling or the
dst buffer needs flushing. For an example, look at the example/zcat program, which uses fixed size buffers, but reads arbitrarily long compressed input from stdin and writes arbitrarily long decompressed output to stdout.
TODO: standardize the various dictionary APIs, after Wuffs v0.2 is released.
In Wuffs syntax, the
base.io_transformer methods are:
set_quirk_enabled!(quirk: u32, enabled: bool)
transform_io?(dst: io_writer, src: io_reader, workbuf: slice u8)
See also the general remarks on Wuffs' standard library.