pub trait Compressor:
Sized
+ 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§
Sourceconst BLOCK_SIZE: usize = 65_280usize
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§
type Error
type CompressionLevel
Required Methods§
Sourcefn new(compression_level: Self::CompressionLevel) -> Self
fn new(compression_level: Self::CompressionLevel) -> Self
Create a new compressor with the given compression level.
Sourcefn default_compression_level() -> Self::CompressionLevel
fn default_compression_level() -> Self::CompressionLevel
Returns the default compression level for the compressor.
Sourcefn 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.
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.