Skip to main content

Inflate

Struct Inflate 

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

The state that is used to decompress an input.

Implementations§

Source§

impl Inflate

Source

pub fn total_in(&self) -> u64

The amount of bytes consumed from the input so far.

Source

pub fn total_out(&self) -> u64

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

Source

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

The error message if the previous operation failed.

Source

pub 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.

Source

pub fn reset(&mut self, zlib_header: bool)

Reset the state to allow handling a new stream.

Source

pub 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.

Source

pub 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.

Source

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

Trait Implementations§

Source§

impl Drop for Inflate

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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.