Expand description
Zstd compression codec for cold/archived partitions.
Higher compression ratio than LZ4 (~5-10x for structured data), slower decompression. Best for sealed partitions that are read infrequently.
Platform strategy:
- Native:
zstdcrate (C libzstd, fastest) - WASM:
ruzstdcrate (pure Rust decoder, no C dependency)
Wire format:
[4 bytes] uncompressed size (LE u32)
[1 byte] compression level used
[N bytes] Zstd frame (standard format, decodable by any Zstd implementation)The 5-byte header prepended to the standard Zstd frame allows us to pre-allocate the output buffer on decode and store the level for metadata.
Structs§
- Zstd
Decoder - Zstd decoder wrapper.
- Zstd
Encoder - Streaming Zstd encoder. Accumulates data and compresses on
finish().
Constants§
- DEFAULT_
LEVEL - Default Zstd compression level (3 = good balance of speed and ratio).
- HIGH_
LEVEL - High compression level for cold storage (19 = near-maximum ratio).
Functions§
- compression_
level - Get the compression level from the header.
- decode
- Decompress Zstd-compressed bytes.
- encode
- Compress raw bytes using Zstd at the default level (3).
- encode_
with_ level - Compress raw bytes using Zstd at a specific level (1-22).
- uncompressed_
size - Get the uncompressed size from the header without decompressing.