Expand description
A small, self-contained LZSS codec for save payloads (feature compress).
Chosen over LZ4/zlib because it is tiny, no_std, allocation-free, and
decodes with only the output buffer as its history window – so a card read
can stream compressed frames straight into the caller’s buffer with no
scratch. Typical structured save data (sparse tables, repeated records)
compresses well; already-dense data falls back to being stored verbatim by
crate::Card::write_compressed.
§Bitstream
Groups of up to 8 tokens, each group prefixed by a flag byte (bit i,
LSB-first, describes token i): 1 = literal (one byte follows), 0 =
match (two bytes follow). A match encodes a 12-bit distance (1..=4096) and a
4-bit length (3..=18) as ((dist-1) << 4) | (len-3), big-endian.
Functions§
- compress
- Compress
srcintodst. Returns the compressed length, orNoneifdstis too small to hold the result. - decompress
- Decompress a full compressed slice into
dst. Returns the number of bytes produced (should equal the original length). Convenience wrapper overdecompress_from. - decompress_
from - Streaming decompression: pull compressed bytes from
nextand write the decoded output intodst, stopping oncedstis full. Returns the number of bytes produced, orNoneon a malformed stream (a back-reference before the start of output, or input exhausted early).