pingora_core::protocols::http::compression

Trait Encode

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

Source

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.

Source

fn stat(&self) -> (&'static str, usize, usize, Duration)

Return the Encoder’s name, the total input bytes, the total output bytes and the total duration spent on encoding the data.

Implementors§