miniz_oxide::inflate

Function decompress_to_vec_with_limit

Source
pub fn decompress_to_vec_with_limit(
    input: &[u8],
    max_size: usize,
) -> Result<Vec<u8>, DecompressError>
Expand description

Decompress the deflate-encoded data in input to a vector.

The vector is grown to at most max_size bytes; if the data does not fit in that size, the error struct will contain the status TINFLStatus::HasMoreOutput and the data that was decompressed on failure.

As this function tries to decompress everything in one go, it’s not ideal for general use outside of tests or where the output size is expected to be small. It is suggested to use streaming decompression via the flate2 library instead.

Returns a Result containing the Vec of decompressed data on success, and a struct on failure.