Expand description
§tinybz2 — Minimal-memory bz2 for embedded targets
A no_std, zero-dependency bz2 compressor and decompressor designed to run
on ESP32 and other memory-constrained microcontrollers.
§Design goals
- ~110 KB peak RAM at block size 1 (100 KB blocks) for both compress and decompress — roughly 10× less than stock libbz2.
- Zero heap allocation — all working memory is caller-provided via fixed-size workspace structs.
no_std+ noalloc— suitable for bare-metal and RTOS targets.- Streaming API — process data in chunks without buffering the entire input.
§Memory budget at block size 1 (100 000 bytes)
| Component | Bytes |
|---|---|
| Block buffer | 100 000 |
| BWT workspace | 512 |
| MTF table | 256 |
| Huffman tables | 10 000 |
| Bookkeeping | 1 024 |
| Total | ~112 KB |
Re-exports§
pub use compress::Compressor;pub use compress::CompressStatus;pub use decompress::Decompressor;pub use decompress::DecompressStatus;pub use error::Error;
Modules§
- bitio
- Bit-level I/O for reading and writing bz2 bitstreams.
- bwt
- Burrows-Wheeler Transform (BWT) — memory-efficient implementation.
- compress
- bz2 compressor — wires together all pipeline stages.
- constants
- bz2 format constants.
- crc
- CRC-32 for bz2 streams.
- decompress
- bz2 decompressor — reads a bz2 bitstream and reconstructs the original data.
- error
- Error types for tinybz2.
- huffman
- Huffman coding for bz2.
- mtf
- Move-to-Front Transform.
- rle1
- RLE1 — Initial run-length encoding.
- rle2
- RLE2 — Zero run-length encoding (RUNA/RUNB).
Functions§
- compress
- One-shot compress into a caller-provided output buffer.
- decompress
- One-shot decompress into a caller-provided output buffer.