Trait gzp::FormatSpec [−][src]
pub trait FormatSpec: Clone + Copy + Debug + Send + Sync + 'static {
type C: Check + Send + 'static;
type Compressor;
const DEFAULT_BUFSIZE: usize;
fn new() -> Self;
fn needs_dict(&self) -> bool;
fn create_compressor(
&self,
compression_level: Compression
) -> Result<Self::Compressor, GzpError>;
fn encode(
&self,
input: &[u8],
encoder: &mut Self::Compressor,
compression_level: Compression,
dict: Option<&Bytes>,
is_last: bool
) -> Result<Vec<u8>, GzpError>;
fn header(&self, compression_level: Compression) -> Vec<u8>;
fn footer(&self, check: &Self::C) -> Vec<u8>;
fn create_check() -> Self::C { ... }
fn to_bytes(&self, pairs: &[Pair]) -> Vec<u8> { ... }
}
Expand description
Defines how to write the header and footer for each format.
Associated Types
Associated Constants
const DEFAULT_BUFSIZE: usize
const DEFAULT_BUFSIZE: usize
The default buffersize to use for this format
Required methods
fn needs_dict(&self) -> bool
fn needs_dict(&self) -> bool
Whether or not this format should try to use a dictionary.
fn create_compressor(
&self,
compression_level: Compression
) -> Result<Self::Compressor, GzpError>
fn create_compressor(
&self,
compression_level: Compression
) -> Result<Self::Compressor, GzpError>
Create a thread local compressor
How to deflate bytes for this format. Returns deflated bytes.
fn header(&self, compression_level: Compression) -> Vec<u8>
fn header(&self, compression_level: Compression) -> Vec<u8>
Generate a generic header for the given format.
Generate a genric footer for the format.
Provided methods
fn create_check() -> Self::C
fn create_check() -> Self::C
Create a check value for this format that implements Check