feat(embed): const constructors, output accessors and owned tables in flate - #137
Merged
Merged
Conversation
… `flate` Brings `embed::flate` up to date with minizlib's last two commits, so that minizlib can re-export it without losing API: - `Decompressor::new` and `Compressor::new` are `const fn`, and their initial state is all zeros (given an output and table that are), so one can live in a `static` in `.bss`; the stream's start is taken on first use rather than in `new`. - `output()` / `output_mut()` on both, to drain an output between pieces. - `Compressor<'t, O, F, T = &'t mut [u16]>`: the table may be owned, any `T: AsMut<[u16]>`. - `Container::INIT`; `flate` now shares `embed`'s zero-based CRC-32 and Adler-32 instead of keeping its own. Test: the codecs in `static`s, owned vs borrowed tables, outputs drained between pieces. Footprint ceilings for `gzip`, `Compressor` and `BufferedCompressor` raised to keep headroom (1030, 1404 and 1600 bytes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports minizlib's last two commits into
embed::flate. Without them, the minizlib 0.1.1 → re-export switch (KarpelesLab/minizlib#5) would lose API that minizlib's master has gained.const fn newonDecompressorandCompressor. Given an output and a table that start as all zeros, a new codec is all zeros too, so it can live in astaticin.bssand costs no flash. The position where the stream starts is now read on first use, since aconst fncan't ask the output for it.output()/output_mut()on both, so the caller can drain their ownOutputbetween pieces.Compressor<'t, O, F, T = &'t mut [u16]>accepts anyT: AsMut<[u16]>, e.g.[0u16; 4096]. The default type parameter keeps existing code compiling.Container::INIT.flatenow usesembed's own CRC-32 and Adler-32, which start from all zeros like minizlib's do now, and drops its own copy.After folding the feature gates the same way as in #135, the ported files are identical to minizlib's master, apart from removing dead branches.
Footprint
Decompressorgzip, buffer outCompressor, streamsBufferedCompressorNo panic machinery is linked. The ceilings were raised to restore about 5% headroom.
Tests
New
tests/embed_flate_embedding.rs, added to CI's embed test step:statics and reused;These pass locally:
--features all,--all-features,embed,gzipandembed;-D warnings;cargo test --all-featuresand the embed test step;tools/footprint/check.sh.🤖 Generated with Claude Code