Skip to main content

structured_zstd/decoding/
mod.rs

1//! RFC 8878 Zstandard decoder.
2//!
3//! Three entry points are exposed, each with progressively lower-level
4//! control:
5//!
6//! * [`StreamingDecoder`] — implements [`crate::io::Read`] over a compressed
7//!   byte stream, transparently parsing the frame header and concatenated
8//!   frames. The typical choice for application code.
9//! * [`FrameDecoder`] — single-frame interface; use when the caller manages
10//!   the input buffer manually (zero-copy slices, network framing, etc).
11//! * [`DictionaryHandle`] — pre-parsed dictionary handle. Parse the
12//!   dictionary bytes once with [`DictionaryHandle::decode_dict`] and reuse
13//!   the handle across every subsequent decode; saves the per-frame
14//!   dictionary parse cost when the same dictionary is used many times in a
15//!   row.
16//!
17//! Both decoders expose dictionary-aware constructors / methods,
18//! though the exact naming differs:
19//!
20//! * [`StreamingDecoder::new_with_dictionary_handle`] /
21//!   [`StreamingDecoder::new_with_dictionary_bytes`]
22//! * [`FrameDecoder::decode_all_with_dict_handle`] /
23//!   [`FrameDecoder::decode_all_with_dict_bytes`]
24//!
25//! The `_handle` variants reuse a previously parsed
26//! [`DictionaryHandle`]; the `_bytes` variants parse the dictionary
27//! per call (suitable for one-off decodes).
28//!
29//! Errors surface through [`errors::FrameDecoderError`] and the per-decoder
30//! error types in the [`errors`] submodule.
31
32pub mod errors;
33mod frame_decoder;
34mod streaming_decoder;
35
36pub use dictionary::{Dictionary, DictionaryHandle};
37pub use frame_decoder::{BlockDecodingStrategy, FrameDecoder};
38pub use streaming_decoder::StreamingDecoder;
39
40pub(crate) mod block_decoder;
41pub(crate) mod buffer_backend;
42pub(crate) mod decode_buffer;
43pub(crate) mod dictionary;
44// FlatBuf is the compile-time-monomorphised "frame fits in window"
45// backend selected via `DecodeBuffer<FlatBuf>`. `FrameDecoder`'s
46// `DecoderScratchKind` picks it when the frame header has
47// `Single_Segment_flag` set; the ring backend remains the default
48// for multi-segment frames. See backlog item #132 for the wiring
49// rationale.
50pub(crate) mod flat_buf;
51pub(crate) mod frame;
52pub(crate) mod literals_section_decoder;
53pub(crate) mod prefetch;
54mod ringbuffer;
55#[allow(dead_code)]
56pub(crate) mod scratch;
57pub(crate) mod sequence_execution;
58pub(crate) mod sequence_section_decoder;
59mod simd_copy;
60
61#[cfg(feature = "bench_internals")]
62pub(crate) use self::simd_copy::copy_bytes_overshooting_for_bench;