Skip to main content

Compressor

Trait Compressor 

Source
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§

Source

fn format(&self) -> CompressionFormat

The format this compressor produces.

Source

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.

Source

fn finish(&mut self, out: &mut Vec<u8>) -> Result<(), CompressError>

Finalize the stream, appending the last frame (if any) to out.

Must be called exactly once; afterwards the compressor is spent.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§