pub struct AdaptiveCompressor { /* private fields */ }Expand description
Adaptive compressor with auto-probe.
Frame format for compressed data: [algo:1][data:N]
If compression is skipped, raw data is returned with algo=0.
Implementations§
Source§impl AdaptiveCompressor
impl AdaptiveCompressor
Sourcepub fn new(algo: CompressionAlgo) -> Self
pub fn new(algo: CompressionAlgo) -> Self
Create with specified algorithm
Sourcepub fn algorithm(&self) -> CompressionAlgo
pub fn algorithm(&self) -> CompressionAlgo
Currently active algorithm (may be None if auto-probe disabled it)
Sourcepub fn compress(&mut self, data: &[u8]) -> (u8, Vec<u8>)
pub fn compress(&mut self, data: &[u8]) -> (u8, Vec<u8>)
Compress data. Returns (algo_byte, compressed_data).
If compression is off, skipped for small data, or output >= input: returns (0, original_data_clone).
Sourcepub fn decompress(
algo_byte: u8,
data: &[u8],
) -> Result<Vec<u8>, CompressionError>
pub fn decompress( algo_byte: u8, data: &[u8], ) -> Result<Vec<u8>, CompressionError>
Decompress data given the algorithm byte, bounding the output to
MAX_DECOMPRESSED_LEN. An input that would expand beyond the cap is
rejected with CompressionError::OutputTooLarge rather than allocated.
Sourcepub fn decompress_with_limit(
algo_byte: u8,
data: &[u8],
max_output: usize,
) -> Result<Vec<u8>, CompressionError>
pub fn decompress_with_limit( algo_byte: u8, data: &[u8], max_output: usize, ) -> Result<Vec<u8>, CompressionError>
Decompress with a caller-chosen output cap. max_output is the largest
plaintext the caller is willing to materialise; the decoders refuse to
allocate or emit beyond it, so a decompression bomb cannot exhaust memory.
Sourcepub fn stats(&self) -> &CompressionStats
pub fn stats(&self) -> &CompressionStats
Compression stats
Sourcepub fn reset_probe(&mut self)
pub fn reset_probe(&mut self)
Reset auto-probe state