Skip to main content

Codec

Trait Codec 

Source
pub trait Codec: Compressor + Decompressor {
    // Required methods
    fn new() -> Self
       where Self: Sized;
    fn with_level(level: CompressionLevel) -> Self
       where Self: Sized;

    // Provided methods
    fn verify_roundtrip(&self, data: &[u8]) -> Result<bool> { ... }
    fn measure_ratio(&self, data: &[u8]) -> Result<CompressionRatio> { ... }
}
Expand description

Combined codec for both compression and decompression.

Required Methods§

Source

fn new() -> Self
where Self: Sized,

Create a new codec with default settings.

Source

fn with_level(level: CompressionLevel) -> Self
where Self: Sized,

Create a new codec with specified level.

Provided Methods§

Source

fn verify_roundtrip(&self, data: &[u8]) -> Result<bool>

Round-trip test: compress then decompress. Returns true if data matches.

Source

fn measure_ratio(&self, data: &[u8]) -> Result<CompressionRatio>

Get compression ratio for given data.

Implementors§