pub struct Deflate(/* private fields */);Expand description
The state that is used to compress an input.
Implementations§
Source§impl Deflate
impl Deflate
Sourcepub fn error_message(&self) -> Option<&'static str>
pub fn error_message(&self) -> Option<&'static str>
The error message if the previous operation failed.
Sourcepub fn new(level: i32, zlib_header: bool, window_bits: u8) -> Self
pub fn new(level: i32, zlib_header: bool, window_bits: u8) -> Self
Create a new instance - this allocates so should be done with care.
The window_bits must be in the range 8..=15, with 15 being most common.
Sourcepub fn compress(
&mut self,
input: &[u8],
output: &mut [u8],
flush: DeflateFlush,
) -> Result<Status, DeflateError>
pub fn compress( &mut self, input: &[u8], output: &mut [u8], flush: DeflateFlush, ) -> Result<Status, DeflateError>
Compress input and write compressed bytes to output, with flush controlling additional characteristics.
Sourcepub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<u32, DeflateError>
pub fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<u32, DeflateError>
Specifies the compression dictionary to use.
Returns the Adler-32 checksum of the dictionary.
Sourcepub fn set_level(&mut self, level: i32) -> Result<Status, DeflateError>
pub fn set_level(&mut self, level: i32) -> Result<Status, DeflateError>
Dynamically updates the compression level.
This can be used to switch between compression levels for different
kinds of data, or it can be used in conjunction with a call to Deflate::reset
to reuse the compressor.
This may return an error if there wasn’t enough output space to complete the compression of the available input data before changing the compression level. Flushing the stream before calling this method ensures that the function will succeed on the first call.