pub struct Deflate { /* private fields */ }Expand description
Compress
Implementations§
Source§impl Deflate
Compress
impl Deflate
Compress
pub fn new_default() -> Result<Self, ZError>
Sourcepub fn new(
level: c_int,
strategy: c_int,
window_bits: c_int,
) -> Result<Self, ZError>
pub fn new( level: c_int, strategy: c_int, window_bits: c_int, ) -> Result<Self, ZError>
Use zlib’s magic constants:
- level =
Z_BEST_SPEED(1) toZ_BEST_COMPRESSION(9) - strategy =
Z_DEFAULT_STRATEGY,Z_FILTERED,Z_HUFFMAN_ONLY,Z_RLE,Z_FIXED - window_bits = 15
Sourcepub fn new_with_vec(
level: c_int,
strategy: c_int,
window_bits: c_int,
buf: Vec<u8>,
) -> Result<Self, ZError>
pub fn new_with_vec( level: c_int, strategy: c_int, window_bits: c_int, buf: Vec<u8>, ) -> Result<Self, ZError>
Same as new, but can append to any Vec
Sourcepub fn tune(
&mut self,
good_length: i32,
max_lazy: i32,
nice_length: i32,
max_chain: i32,
) -> Result<(), ZError>
pub fn tune( &mut self, good_length: i32, max_lazy: i32, nice_length: i32, max_chain: i32, ) -> Result<(), ZError>
Change compression parameters to fine tune space-speed tradeoff.
Sourcepub fn reserve(&mut self, compressed_size: usize)
pub fn reserve(&mut self, compressed_size: usize)
Expect (remaining) data to take this much space after compression
Sourcepub fn compress(&mut self, data: &[u8]) -> Result<(), ZError>
pub fn compress(&mut self, data: &[u8]) -> Result<(), ZError>
Add bytes from data to compressed data
Sourcepub fn compress_with_limit(
&mut self,
data: &[u8],
max_size: &AtomicUsize,
) -> Result<(), ZError>
pub fn compress_with_limit( &mut self, data: &[u8], max_size: &AtomicUsize, ) -> Result<(), ZError>
dd bytes from data to compressed data, unless the total compressed output would exceed max_size
pub fn finish(self) -> Result<Vec<u8>, ZError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Deflate
impl RefUnwindSafe for Deflate
impl !Send for Deflate
impl !Sync for Deflate
impl Unpin for Deflate
impl UnwindSafe for Deflate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more