pub trait CompressionCodec: Send + Sync {
// Required methods
fn id(&self) -> CodecId;
fn compress(&self, data: &[u8]) -> Result<Vec<u8>>;
fn decompress(
&self,
data: &[u8],
uncompressed_size: usize,
) -> Result<Vec<u8>>;
}Expand description
A compression codec that can compress and decompress block data.
Implementations must be Send + Sync so they can be shared across
threads and async tasks.
§Extensibility
Implement this trait to add support for custom compression algorithms
(e.g. zstd, lz4, snappy). Register the codec by its
CodecId::Named identifier.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".