Skip to main content

Crate autozstd

Crate autozstd 

Source
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§

Adaptiveadaptive
Network-, worker-, latency-, and content-aware compression policy.
EncodeOpt
Encoding parameters combining Level with an explicit window memory bound.
Encoded
Encoded payload with the type tag kept separate from the payload buffer.
NetSignaladaptive
Real-time link, concurrency, latency, and memory signals for compression decisions.
Statadaptive
Estimated behavior of one level.

Enums§

Choiceadaptive
Chosen compression mode.
ContentBucket
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_log cap (21 -> 2 MiB max window), keeping per-thread memory bounded.
LOW_LATENCY_WINDOW_LOG
Low-latency window_log cap (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 exceeds max_len bytes.
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_len bytes.
decode_payload_limit
Decodes a payload whose Type tag was transmitted out of band, enforcing max_len.
encode
Compresses data into an envelope with default DEFAULT_MAX_WINDOW_LOG.
encode_into
Encodes into out reusing capacity with default DEFAULT_MAX_WINDOW_LOG.
encode_into_opt
Encodes into out with explicit EncodeOpt, reusing its capacity.
encode_opt
Compresses data into an envelope with explicit EncodeOpt.
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.

Type Aliases§

Result
Result alias with Error.