Deflate

Struct Deflate 

Source
pub struct Deflate { /* private fields */ }
Expand description

Compress

Implementations§

Source§

impl Deflate

Compress

Source

pub fn new_default() -> Result<Self, ZError>

Source

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) to Z_BEST_COMPRESSION (9)
  • strategy = Z_DEFAULT_STRATEGY, Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED
  • window_bits = 15
Source

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

Source

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.

Source

pub fn reserve(&mut self, compressed_size: usize)

Expect (remaining) data to take this much space after compression

Source

pub fn compress(&mut self, data: &[u8]) -> Result<(), ZError>

Add bytes from data to compressed data

Source

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

Source

pub fn finish(self) -> Result<Vec<u8>, ZError>

Trait Implementations§

Source§

impl Drop for Deflate

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.