Expand description
Zstd envelope compression with automatic raw fallback and window-bounded memory.
An envelope is [type][payload]: the first byte is a Type, and the
payload is either the input unchanged or a magicless Zstandard frame.
Inputs shorter than 7 bytes, known compressed formats, and O(1)-sampled
high-entropy payloads fall back directly to raw bytes without running Zstd.
Encoder window size is clamped by both input length and EncodeOpt::max_window_log
to bound per-thread memory (O(min(len, 2^max_window_log))).
The optional adaptive feature adds Adaptive and NetSignal, modeling
hybrid serial/pipeline overlap cost across content buckets (Low, Medium, High)
and calibrating hardware speed across architectures.
Structs§
- Adaptive
adaptive - Network-, worker-, latency-, and content-aware compression policy.
- Encode
Opt - Encoding parameters combining
Levelwith an explicit window memory bound. - Encoded
- Encoded payload with the type tag kept separate from the payload buffer.
- NetSignal
adaptive - Real-time link, concurrency, latency, and memory signals for compression decisions.
- Stat
adaptive - Estimated behavior of one level.
Enums§
- Choice
adaptive - Chosen compression mode.
- Content
Bucket - Coarse compressibility class estimated in O(1) time and stack space.
- Error
- Errors returned when decoding an envelope.
- Level
- Compression level presets spanning ultra-fast negative levels to level 19.
- Type
- Payload kind, stored in the first byte of an envelope.
Constants§
- DEFAULT_
MAX_ WINDOW_ LOG - Default
window_logcap (21-> 2 MiB max window), keeping per-thread memory bounded. - LOW_
LATENCY_ WINDOW_ LOG - Low-latency
window_logcap (15-> 32 KiB max window) for terminal/RPC frames.
Functions§
- classify
- Estimates data compressibility in strict O(1) time and stack memory (~544 B).
- decode
- Decodes an envelope produced by
encode. - decode_
limit - Decodes an envelope produced by
encode, rejecting any payload whose decoded size exceedsmax_lenbytes. - decode_
owned - Decodes an owned envelope, reusing its buffer for raw payloads.
- decode_
owned_ limit - Decodes an owned envelope, rejecting any payload whose decoded size exceeds
max_lenbytes. - decode_
payload_ limit - Decodes a payload whose
Typetag was transmitted out of band, enforcingmax_len. - encode
- Compresses
datainto an envelope with defaultDEFAULT_MAX_WINDOW_LOG. - encode_
into - Encodes into
outreusing capacity with defaultDEFAULT_MAX_WINDOW_LOG. - encode_
into_ opt - Encodes into
outwith explicitEncodeOpt, reusing its capacity. - encode_
opt - Compresses
datainto an envelope with explicitEncodeOpt. - encode_
owned - Encodes an owned buffer with default
DEFAULT_MAX_WINDOW_LOG. - encode_
owned_ opt - Encodes an owned buffer with explicit
EncodeOpt, keeping it untouched on raw fallback.