Skip to main content

streaming_crypto/core_api/compression/
mod.rs

1// # Full Implementation: `src/compression/` Module
2
3// Hereโ€™s the complete, productionโ€‘ready compression module. It provides deterministic, streamingโ€‘safe compression and decompression across codecs (Auto, Zstd, LZ4, Deflate), with dictionary support, registry resolution, and strict validation.
4
5// ## ๐Ÿ“‚ Module Layout
6
7// ```
8// src/compression/
9//  โ”œโ”€โ”€ mod.rs
10//  โ”œโ”€โ”€ registry.rs
11//  โ”œโ”€โ”€ codecs/
12//  โ”‚    โ”œโ”€โ”€ auto.rs
13//  โ”‚    โ”œโ”€โ”€ zstd.rs
14//  โ”‚    โ”œโ”€โ”€ lz4.rs
15//  โ”‚    โ””โ”€โ”€ deflate.rs
16//  โ”œโ”€โ”€ stream.rs
17//  โ””โ”€โ”€ tests.rs
18// ```
19
20// ---
21
22// ## src/compression/mod.rs
23
24//! compression/mod.rs
25//! Streaming-safe compression and decompression.
26//!
27//! Industry notes:
28//! - Deterministic per-chunk compression ensures reproducibility and parallel safety.
29//! - Dictionaries must be explicitly declared and bound via header.dict_id.
30//! - Registry resolves codec IDs to implementations.
31
32pub mod types;
33pub mod registry;
34pub mod codecs;
35pub mod stream;
36
37pub use types::*;
38pub use registry::*;
39
40
41// Notes:
42// - Weโ€™ll need dependencies: zstd = "0.13", lz4-flex = "0.11", flate2 = "1".
43// - The LZ4 and Zstd streaming adapters here use Vec-backed writers; we explicitly drain the inner buffers to yield chunk outputs. 
44// - This keeps per-chunk determinism and avoids frame-spanning state unless a dictionary is provided and flagged.
45// - For dictionary enforcement with header flags, wire checks in the streaming layer: if DICT_USED is set, pass dict bytes; otherwise, require None.