Struct Inflate

pub struct Inflate { /* private fields */ }

The state that is used to decompress an input.

Implementations

impl Inflate

fn total_in(&self) -> u64

The amount of bytes consumed from the input so far.

fn total_out(&self) -> u64

The amount of decompressed bytes that have been written to the output thus far.

fn error_message(&self) -> Option<&'static str>

The error message if the previous operation failed.

fn new(expect_header: bool, window_bits: u8) -> Self

Create a new instance. This function allocates, and so it is recommended to re-use this state when possible, using Inflate::reset as needed.

This function will:

  • decode a raw deflate stream when expect_header = false and window_bits is in the range 8..=15
  • decode a zlib header followed by a deflate stream when expect_header = true and window_bits is in the range 8..=15
  • decode a gzip header followed by a deflate stream when expect_header = true and window_bits is in the range 16 + 8..=16 + 15
  • decode either a zlib or a gzip header, followed by a deflate stream when expect_header = true and window_bits is in the range 32 + 8..=32 + 15

window_bits can also be 0 to request that inflate use the window size in the zlib header of the compressed stream when using zlib.

Note that when deflating a value of window_bits = 8 is silently converted to window_bits = 9 in most zlib implementations, and hence should be inflated using window_bits = 9.

Panics

This function may panic when the window_bits and expect_header have values not listed above.

fn reset(&mut self, zlib_header: bool)

Reset the state to allow handling a new stream.

fn decompress(&mut self, input: &[u8], output: &mut [u8], flush: InflateFlush) -> Result<Status, InflateError>

Decompress input and write all decompressed bytes into output, with flush defining some details about this.

fn decompress_uninit(&mut self, input: &[u8], output: &mut [MaybeUninit<u8>], flush: InflateFlush) -> Result<Status, InflateError>

Decompress input and write all decompressed bytes into a potentially uninitialized output, with flush defining some details about this.

fn set_dictionary(&mut self, dictionary: &[u8]) -> Result<u32, InflateError>

Trait Implementations

impl Drop for Inflate

fn drop(&mut self)

Auto Trait Implementations

impl !UnwindSafe for Inflate

impl Freeze for Inflate

impl RefUnwindSafe for Inflate

impl Send for Inflate

impl Sync for Inflate

impl Unpin for Inflate

impl UnsafeUnpin for Inflate

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for Inflate

fn from(t: T) -> T

Returns the argument unchanged.

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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