Trait pooled_writer::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;
fn new(compression_level: Self::CompressionLevel) -> Self;
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.
Associated Types
Associated Constants
const BLOCK_SIZE: usize
const BLOCK_SIZE: usize
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 methods
fn new(compression_level: Self::CompressionLevel) -> Self
fn new(compression_level: Self::CompressionLevel) -> Self
Create a new compressor with the given compression level.
fn new_compression_level(
compression_level: u8
) -> Result<Self::CompressionLevel, Self::Error>
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.