pub trait Encode {
// Required methods
fn encode(&mut self, input: &[u8], end: bool) -> Result<Bytes>;
fn stat(&self) -> (&'static str, usize, usize, Duration);
}
Expand description
The trait for both compress and decompress because the interface and syntax are the same: encode some bytes to other bytes
Required Methods§
Sourcefn encode(&mut self, input: &[u8], end: bool) -> Result<Bytes>
fn encode(&mut self, input: &[u8], end: bool) -> Result<Bytes>
Encode the input bytes. The end
flag signals the end of the entire input. The end
flag
helps the encoder to flush out the remaining buffered encoded data because certain compression
algorithms prefer to collect large enough data to compress all together.