pub trait Compressor: Send {
// Required methods
fn format(&self) -> CompressionFormat;
fn compress(
&mut self,
input: &[u8],
out: &mut Vec<u8>,
) -> Result<(), CompressError>;
fn finish(&mut self, out: &mut Vec<u8>) -> Result<(), CompressError>;
}Expand description
Streaming compressor. Feed it bounded input chunks; it appends the compressed bytes produced so far to the provided output buffer.
Required Methods§
Sourcefn format(&self) -> CompressionFormat
fn format(&self) -> CompressionFormat
The format this compressor produces.
Sourcefn compress(
&mut self,
input: &[u8],
out: &mut Vec<u8>,
) -> Result<(), CompressError>
fn compress( &mut self, input: &[u8], out: &mut Vec<u8>, ) -> Result<(), CompressError>
Compress input, appending compressed bytes to out.
input should be kept ≤ CHUNK_SIZE to keep
the output frames small and memory constant. When the next chunk
arrives, the previous chunk’s frame is finalized and emitted.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".