Expand description
Codec registry — dispatches compression/decompression by codec id.
Each drop record carries a representation triple (codec, aead, ec).
This module centralises codec dispatch behind a Codec trait and a
CodecRegistry, so adding a codec is a new file + one registration
call (open/closed). The existing free functions compress and
decompress remain as thin wrappers around the default registry.
§Supported codecs
| Id | Name | Encode | Decode | Notes |
|---|---|---|---|---|
| 0x00 | store | yes (identity) | yes | No compression |
| 0x01 | lz4 | yes (lz4_flex) | yes | Fast baseline; pure Rust |
| 0x02 | zstd | yes (ruzstd Fastest) | yes (ruzstd) | Pure Rust; ZSTD level 1 |
| 0x03 | xz | yes (omnizip-lzma) | yes (omnizip-lzma) | LZMA2 in XZ container |
| 0x04 | brotli | yes (brotli q11) | yes (brotli) | Best ratio; pure Rust |
| 0x05 | deflate | yes (miniz_oxide) | yes (miniz_oxide) | RFC 1951; universal interop; pure Rust |
| 0x06 | snappy | yes (omnizip-snappy) | yes (omnizip-snappy) | Google’s high-speed codec; pure Rust |
100% pure Rust. No C libraries. Air-gapped safe.
Modules§
- fsst_
brotli - FSST + Brotli composite codec (id 0x09).
- zstd_
dict - ZSTD dictionary codec operations.
Structs§
- Codec
Registry - Process-wide registry of codecs, keyed by codec id.
- Codec
Tunables - Codec-agnostic tunables. Every codec reads only the fields it
understands; the rest are ignored. The struct is the
single source of truth for “what knobs does the writer want to
turn” — adding a new knob is one field here, not a new
compress_with_*function per codec (OCP).
Constants§
- CODEC_
BCJ_ ARM64_ LZ4 - Codec id 0x23: BCJ-ARM64 filter + LZ4. For AArch64 executables.
- CODEC_
BCJ_ ARM64_ ZSTD - Codec id 0x24: BCJ-ARM64 filter + ZSTD.
- CODEC_
BCJ_ X86_ LZ4 - Codec id 0x20: BCJ-x86 filter + LZ4. For x86/x86_64 executables.
- CODEC_
BCJ_ X86_ ZSTD - Codec id 0x21: BCJ-x86 filter + ZSTD.
- CODEC_
BITSHUFFLE_ LZ4 - Codec id 0x0F: Bitshuffle+LZ4 (BLOSC2 bit-shuffle + LZ4 back-end).
- CODEC_
BLOS C2_ SHUFFLE_ LZ4 - Codec id 0x0A: BLOSC shuffle + LZ4 for scientific float data.
- CODEC_
BROTLI - Codec id 0x04: Brotli frame format (
brotli, pure Rust). Encode at quality 11 (best ratio); decode at any quality. - CODEC_
BZIP2 - Codec id 0x10:
BZip2. - CODEC_
DEFLATE - Codec id 0x05: DEFLATE stream format (
miniz_oxide, pure Rust). Raw RFC 1951 inside a zlib wrapper (RFC 1950). - CODEC_
DEFLAT E64 - Codec id 0x11: Deflate64 (ZIP method 9, 64 KB window).
- CODEC_
FLAC - Codec id 0x07: FLAC for PCM audio. RESERVED — pending
omnizip-flacencoder port. The wrapper atcodec::flac::FlacCodecreturnsUnsupportedFeatureuntil the real codec lands. - CODEC_
FSST_ BROTLI - Codec id 0x09: FSST + Brotli composite for CSV/JSON.
- CODEC_
GLZA - Codec id 0x0D: GLZA grammar-based LZ.
- CODEC_
LIBDEFLATE - Codec id 0x14: libdeflate-compatible DEFLATE (pure-Rust port).
Wire-compatible with
CODEC_DEFLATE(0x05) — both are RFC 1951 DEFLATE wrapped in RFC 1950 zlib. Different implementation:omnizip-libdeflateis omnizip’s in-house pure-Rust port (LZ77 + fixed-Huffman + canonical Huffman inflate), focused on decode speed;omnizip-deflate(0x05) wrapsminiz_oxide. - CODEC_
LZ4 - Codec id 0x01: LZ4 block format (
lz4_flex, pure Rust). - CODEC_
LZ4_ HC - Codec id 0x13: LZ4 HC (hash-chain match finder + lazy parsing). Real encoder from omnizip-lz4 0.14.1; was a stub in 0.13.1.
- CODEC_
PPMD - Codec id 0x0C:
PPMd(dormant — raw fallback). - CODEC_
PPMD8 - Codec id 0x12: PPMd8 (RESTART + RLE, user-tunable memory budget).
- CODEC_
REFERENCED - Codec id 0xFE: REFERENCED. Sentinel codec id for drops that are not stored in this image’s slabs — the bytes live in a base image and the reader resolves them via the overlay chain.
- CODEC_
RICEPP - Codec id 0x08: Rice++ for FITS / scientific integer-pixel images.
RESERVED — pending
omnizip-riceppencoder port. - CODEC_
SHUFFLE_ ZSTD - Codec id 0x0E: Shuffle+Zstd (BLOSC2 byte-shuffle + Zstd back-end).
- CODEC_
SNAPPY - Codec id 0x06: Snappy format (
omnizip-snappy→snap, pure Rust). No compression levels; ~500 MB/s encode and decode. - CODEC_
STORE - Codec id 0x00: store (no compression).
- CODEC_
XZ - Codec id 0x03: XZ/LZMA2 format via
omnizip-lzma. - CODEC_
ZPAQ - Codec id 0x0B: ZPAQ context-mixing archiver.
- CODEC_
ZSTD - Codec id 0x02: Zstandard frame format (
ruzstd, pure Rust). Encode usesCompressionLevel::Fastest(ZSTD level 1); decode supports any level the reference encoder can produce.
Traits§
- Codec
- The behaviour every compression codec implements. New codecs register
a
Codecimpl withCodecRegistry::register; the dispatch code never changes. - PerCodec
Tunables - Optional trait: codecs with strongly-typed per-codec tunables.
Functions§
- best_
binary_ codec - Returns the best available codec for binary content classes (structured binary — ELF, Mach-O, PE, object files, etc.).
- best_
compressible_ codec - Returns the best available codec for compressible content classes
(Text, Code). Brotli q5 is the current default — beats ZSTD L6
(omnizip 0.7+) on real source code in our benchmarks. Try
switching to
CODEC_ZSTDif ZSTD’s level differentiation improves enough to beat Brotli; the change is one line. - codec_
name - Human-readable name for a registered codec id, e.g. for CLI inspection output.
- compress
- Compress
plaintextusing the codec identified bycodec_id, via the process-wide defaultCodecRegistry. - compress_
brotli - Compress with Brotli at quality 11 (best ratio).
- compress_
brotli_ with_ quality - Compress with Brotli at an explicit quality (0–11). Quality 0 is the fastest; quality 11 is the reference encoder’s maximum.
- compress_
deflate - Compress with DEFLATE at level 6 (default). Output is a zlib-framed
DEFLATE stream (RFC 1950) decodable by any zlib decoder (
gzip -d,zlib.decompress, etc.). - compress_
lz4_ with_ size - Compress with LZ4, prepending the original size as a 4-byte LE
header. Routes through
omnizip-lz4::Lz4FastCodecso callers stay first-party (omnizip) for the codec implementation. - compress_
with_ options - Compress with a quality/level hint. For codecs that support a quality parameter (Brotli, ZSTD), this overrides the default. For codecs without quality control (LZ4, Store, Snappy), the hint is silently ignored.
- compress_
with_ tunables - Compress
plaintextwith the given codec and tunables. Codecs that don’t overridecompress_with_tunableson theCodectrait fall back to plaincompress. - compress_
zstd - Compress with Zstandard at
CompressionLevel::Fastest(ZSTD level 1). The output is a standard ZSTD frame decodable by any conformant ZSTD decoder. - decompress
- Decompress
compressedusing the codec identified bycodec_id, via the process-wide defaultCodecRegistry. Theexpected_lenis theplaintext_lenfrom the drop record; the decompressed output MUST match it exactly.