Skip to main content

Module zstd

Module zstd 

Source
Expand description

Trained-dictionary zstd compression for PJS byte-level transport (Layer B).

Provides ZstdDictionary (a validated opaque blob carrying the libzstd dictionary) and ZstdDictCompressor (a stateless driver for training, compression, and standalone decompression).

The hot-path decompression used by crate::compression::secure::SecureCompressor is intentionally not exposed here: it uses a streaming decoder routed through CompressionBombProtector so the output-size guard still applies. This module’s decompress is only for callers that need a standalone, non-bomb-protected path (e.g., tests or tools where the size is already known).

Available only when feature = "compression" is enabled and the target is not wasm32.

Structs§

ZstdDictCompressor
Stateless driver for zstd dictionary operations.
ZstdDictionary
A validated, size-bounded zstd dictionary blob.

Constants§

DEFAULT_LEVEL
Default zstd compression level used by ZstdDictCompressor::compress.
MAX_DICT_SIZE
Maximum permitted dictionary size in bytes (112 KiB).
N_TRAIN
Number of training samples required before ZstdDictCompressor::train is called. Libzstd requires at least 8 samples; N_TRAIN is set to 32 so the resulting dictionary captures representative variance across a session. Below this threshold crate::domain::ports::dictionary_store::DictionaryStore::get_dictionary returns Ok(None).