Struct Decompress
struct Decompress { ... }
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
impl Decompress
fn new(zlib_header: bool) -> DecompressCreates a new object ready for decompressing data that it's given.
The
zlib_headerargument indicates whether the input data is expected to have a zlib header or not.fn new_with_window_bits(zlib_header: bool, window_bits: u8) -> DecompressCreates a new object ready for decompressing data that it's given.
The
zlib_headerargument indicates whether the input data is expected to have a zlib header or not. Thewindow_bitsparameter indicates the base-2 logarithm of the sliding window size and must be between 9 and 15.Panics
If
window_bitsdoes not fall into the range 9 ..= 15,new_with_window_bitswill panic.fn new_gzip(window_bits: u8) -> DecompressCreates 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_bitsdoes not fall into the range 9 ..= 15,new_with_window_bitswill panic.fn total_in(self: &Self) -> u64Returns the total number of input bytes which have been processed by this decompression object.
fn total_out(self: &Self) -> u64Returns the total number of output bytes which have been produced by this decompression object.
fn decompress(self: &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
FlushDecompressparameters.If the first call passes
FlushDecompress::Finishit 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::Finishindicates 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_inandtotal_outfunctions before/after this is called.Errors
If the input data to this instance of
Decompressis not a valid zlib/deflate stream then this function may return an instance ofDecompressErrorto indicate that the stream of input bytes is corrupted.fn decompress_uninit(self: &mut Self, input: &[u8], output: &mut [MaybeUninit<u8>], flush: FlushDecompress) -> Result<Status, DecompressError>Similar to
Self::decompressbut accepts uninitialized bufferIf you want to avoid the overhead of zero initializing the buffer and you don't want to use a
Vec, then please use this API.fn decompress_vec(self: &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 ofvecis 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
Decompressis not a valid zlib/deflate stream then this function may return an instance ofDecompressErrorto indicate that the stream of input bytes is corrupted.fn set_dictionary(self: &mut Self, dictionary: &[u8]) -> Result<u32, DecompressError>Specifies the decompression dictionary to use.
fn reset(self: &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.
impl Debug for Decompress
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for Decompress
impl RefUnwindSafe for Decompress
impl Send for Decompress
impl Sync for Decompress
impl Unpin for Decompress
impl UnsafeUnpin for Decompress
impl UnwindSafe for Decompress
impl<T> Any for Decompress
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Decompress
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Decompress
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Decompress
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Decompress
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Decompress
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Decompress
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>