Skip to content

feat(embed): embed::flate, the low-level API absorbed from minizlib - #135

Merged
MagicalTux merged 1 commit into
masterfrom
embed-flate
Oct 3, 2026
Merged

MagicalTux merged 1 commit into
masterfrom
embed-flate

Conversation

@MagicalTux

Copy link
Copy Markdown
Member

What

Adds compcol::embed::flate (needs embed + deflate), which is the full public API of the minizlib crate. Once this ships as 0.7.1, minizlib becomes a deprecated re-export of it, with no change to its API.

Unlike the Encoder / Decoder codecs, which own their window and table, this module uses only memory the caller provides:

  • Decoding: gunzip / unzlib / inflate / decompress (autodetects gzip or zlib), and *_len to only count. Output goes into the caller's Buffer (which doubles as the history window), through a Stream window of any size, or into a Counter. Input is pulled through Reader (a callback), Bytes (an iterator) or any Input, or pushed into a Decompressor.
  • Compressing: gzip / zlib / deflate, Compressor (one chunk at a time) and BufferedCompressor, all using a hash table the caller provides, of any size.
  • Errors: its own Error, which keeps I/O failures (Io) and a too-small window (WindowTooSmall) apart from other errors.

minizlib's fine-grained features are fixed at their defaults:

  • checksums are always verified;
  • concatenated gzip members and all three block types are always decoded;
  • CRC-32 uses the 16-entry table, shared with embed's own codecs.

Footprint

Seven flate configurations are added to tools/footprint. Their ceilings are documented in compcol::embed and README. None links any panic machinery, and the measurements match minizlib 0.1 to within a few bytes:

configuration code stack
gunzip, buffer out 2430 1376
gunzip, streams 2756 1520
gunzip_len 2288 1376
Decompressor 3460 1448
gzip, buffer out 982 160
Compressor, streams 1344 792
BufferedCompressor 1522 400

flate's CRC-32 and Adler-32 start from their standard initial values, not from all zeros. With all zeros, LLVM clears a Decompressor with memclr8, which links about 200 extra bytes.

Tests

minizlib's test suite is ported as tests/embed_flate_*.rs, and CI's embed test step now runs it.

  • Round trips against flate2, a new dev-dependency.
  • Every kind of input and output.
  • Streams truncated and corrupted.
  • Push input cut into pieces of every size.

These checks pass locally:

  • fmt;
  • clippy on --features all, --all-features, embed,gzip and embed;
  • rustdoc with -D warnings;
  • cargo test --all-features;
  • the thumbv7em build;
  • the MSRV 1.88 check;
  • tools/footprint/check.sh.

🤖 Generated with Claude Code

Adds `compcol::embed::flate` (with `embed` + `deflate`): the full API of
the retired minizlib crate, so that minizlib can become a re-export of it.
The memory is all the caller's: decode into the caller's buffer or through
a window of any size, pull input through a callback (`Reader`), an iterator
(`Bytes`) or any `Input`, or push it (`Decompressor`); output to a `Buffer`,
a `Stream` callback or a `Counter`; compress a chunk at a time with the
caller's table (`Compressor`, `BufferedCompressor`). It has its own `Error`,
which tells I/O failures and too small a window apart.

minizlib's fine-grained features are fixed to their defaults: checksums
verified, concatenated gzip members and all block types decoded, 16-entry
CRC-32 table (shared with `embed`'s own codecs).

- Tests: minizlib's suite, round-tripping against flate2 (new dev-dep).
- Footprint: seven `flate` configurations added to tools/footprint, with
  ceilings documented in `compcol::embed`; no panic machinery linked, sizes
  within a few bytes of minizlib 0.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MagicalTux
MagicalTux merged commit 8c6eaaf into master Oct 3, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant