Skip to main content

Compressor

Trait Compressor 

Source
pub trait Compressor:
    Send
    + Sync
    + Debug {
    // Required methods
    fn compress(&self, data: &[u8]) -> CompressionResult<Vec<u8>>;
    fn decompress(&self, data: &[u8]) -> CompressionResult<Vec<u8>>;
}
Expand description

Compressor trait for pluggable compression implementations

Implementations must support transparent compression and decompression with configurable levels.

Required Methods§

Source

fn compress(&self, data: &[u8]) -> CompressionResult<Vec<u8>>

Compress data

§Arguments
  • data - Raw data to compress
§Returns

Compressed data with algorithm identification prefix

§Errors

Returns CompressionError if compression fails

Source

fn decompress(&self, data: &[u8]) -> CompressionResult<Vec<u8>>

Decompress data

Automatically detects compression algorithm from data prefix

§Arguments
  • data - Compressed data (or raw data without compression)
§Returns

Decompressed data

§Errors

Returns CompressionError if decompression fails

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§