Skip to main content

decompress_to_buffer

Function decompress_to_buffer 

Source
pub fn decompress_to_buffer(
    source: &[u8],
    destination: &mut [u8],
) -> Result<usize>
Expand description

Decompress a single block of data to the given destination buffer.

Returns the number of bytes written, or an error if something happened (for instance if the destination buffer was too small).

crate::decompressed_size() says how big the result will be, when the frame records it - there is no need to store the size alongside the data yourself. Passing a Vec instead of a slice works too, and then it is the Vec’s capacity that bounds the output, so reserve what you need rather than resize.