Trait rusty_leveldb_arc::compressor::Compressor
source · pub trait Compressor {
// Required methods
fn encode(&self, block: Vec<u8>) -> Result<Vec<u8>>;
fn decode(&self, block: Vec<u8>) -> Result<Vec<u8>>;
}
Expand description
Custom compression method
#[derive(Debug, Clone, Copy, Default)]
pub struct CustomCompressor;
impl CompressorId for CustomCompressor {
// a unique id to identify what compressor should DB use
const ID: u8 = 42;
}
impl Compressor for CustomCompressor {
fn encode(&self, block: Vec<u8>) -> rusty_leveldb_arc::Result<Vec<u8>> {
// Do something
Ok(block)
}
fn decode(&self, block: Vec<u8>) -> rusty_leveldb_arc::Result<Vec<u8>> {
// Do something
Ok(block)
}
}
See crate::CompressorList for usage