gix_features::zlib

Struct Decompress

Source
pub struct Decompress { /* private fields */ }
Available on crate feature zlib only.
Expand description

Raw in-memory decompression stream for blocks of data.

This type is the building block for the I/O streams in the rest of this crate. It requires more management than the Read/Write API but is maximally flexible in terms of accepting input from any source and being able to produce output to any memory location.

It is recommended to use the I/O stream adaptors over this type as they’re easier to use.

Implementations§

Source§

impl Decompress

Source

pub fn new(zlib_header: bool) -> Decompress

Creates a new object ready for decompressing data that it’s given.

The zlib_header argument indicates whether the input data is expected to have a zlib header or not.

Source

pub fn new_with_window_bits(zlib_header: bool, window_bits: u8) -> Decompress

Available on crate feature any_zlib only.

Creates a new object ready for decompressing data that it’s given.

The zlib_header argument indicates whether the input data is expected to have a zlib header or not. The window_bits parameter indicates the base-2 logarithm of the sliding window size and must be between 9 and 15.

§Panics

If window_bits does not fall into the range 9 ..= 15, new_with_window_bits will panic.

Source

pub fn new_gzip(window_bits: u8) -> Decompress

Available on crate feature any_zlib only.

Creates a new object ready for decompressing data that it’s given.

The Decompress object produced by this constructor expects gzip headers for the compressed data.

§Panics

If window_bits does not fall into the range 9 ..= 15, new_with_window_bits will panic.

Source

pub fn total_in(&self) -> u64

Returns the total number of input bytes which have been processed by this decompression object.

Source

pub fn total_out(&self) -> u64

Returns the total number of output bytes which have been produced by this decompression object.

Source

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

Decompresses the input data into the output, consuming only as much input as needed and writing as much output as possible.

The flush option can be any of the available FlushDecompress parameters.

If the first call passes FlushDecompress::Finish it is assumed that the input and output buffers are both sized large enough to decompress the entire stream in a single call.

A flush value of FlushDecompress::Finish indicates that there are no more source bytes available beside what’s already in the input buffer, and the output buffer is large enough to hold the rest of the decompressed data.

To learn how much data was consumed or how much output was produced, use the total_in and total_out functions before/after this is called.

§Errors

If the input data to this instance of Decompress is not a valid zlib/deflate stream then this function may return an instance of DecompressError to indicate that the stream of input bytes is corrupted.

Source

pub fn decompress_vec( &mut self, input: &[u8], output: &mut Vec<u8>, flush: FlushDecompress, ) -> Result<Status, DecompressError>

Decompresses the input data into the extra space in the output vector specified by output.

This function has the same semantics as decompress, except that the length of vec is managed by this function. This will not reallocate the vector provided or attempt to grow it, so space for the output must be reserved in the output vector by the caller before calling this function.

§Errors

If the input data to this instance of Decompress is not a valid zlib/deflate stream then this function may return an instance of DecompressError to indicate that the stream of input bytes is corrupted.

Source

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

Available on crate feature any_zlib only.

Specifies the decompression dictionary to use.

Source

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

Performs the equivalent of replacing this decompression state with a freshly allocated copy.

This function may not allocate memory, though, and attempts to reuse any previously existing resources.

The argument provided here indicates whether the reset state will attempt to decode a zlib header first or not.

Trait Implementations§

Source§

impl Debug for Decompress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.