Compressor

Trait Compressor 

Source
pub trait Compressor:
    Sized
    + Send
    + 'static
where Self::CompressionLevel: Clone + Send + 'static, Self::Error: Error + Send + 'static,
{ type Error; type CompressionLevel; const BLOCK_SIZE: usize = 65_280usize; // Required methods fn new(compression_level: Self::CompressionLevel) -> Self; fn default_compression_level() -> Self::CompressionLevel; fn new_compression_level( compression_level: u8, ) -> Result<Self::CompressionLevel, Self::Error>; fn compress( &mut self, input: &[u8], output: &mut Vec<u8>, is_last: bool, ) -> Result<(), Self::Error>; }
Expand description

A Compressor is used in the compressor pool to compress bytes.

An implementation must be provided as a type to the [Pool::new] function so that the pool knows what kind of compression to use.

See the module level example for more details.

Provided Associated Constants§

Source

const BLOCK_SIZE: usize = 65_280usize

The BLOCK_SIZE is used to set the buffer size of the PooledWriters and should match the max size allowed by the block compression format being used.

Required Associated Types§

Required Methods§

Source

fn new(compression_level: Self::CompressionLevel) -> Self

Create a new compressor with the given compression level.

Source

fn default_compression_level() -> Self::CompressionLevel

Returns the default compression level for the compressor.

Source

fn new_compression_level( compression_level: u8, ) -> Result<Self::CompressionLevel, Self::Error>

Create an instance of the compression level.

The validity of the compression level should be checked here.

Source

fn compress( &mut self, input: &[u8], output: &mut Vec<u8>, is_last: bool, ) -> Result<(), Self::Error>

Compress a set of bytes into the output vec. If is_last is true, and depending on the block compression format, an EOF block may be appended as well.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§