pub fn decompress_slice_iter_to_slice<'out, 'inp>(
out: &'out mut [u8],
it: impl Iterator<Item = &'inp [u8]>,
zlib_header: bool,
ignore_adler32: bool,
) -> Result<usize, TINFLStatus>Expand description
Decompress one or more source slices from an iterator into the output slice.
- On success, returns the number of bytes that were written.
- On failure, returns the failure status code.
This will fail if the output buffer is not large enough, but in that case the output buffer will still contain the partial decompression.
outthe output buffer.itthe iterator of input slices.zlib_headerif the first slice out of the iterator is expected to have a Zlib header. Otherwise the slices are assumed to be the deflate data only.ignore_adler32if the adler32 checksum should be validated in case of of zlib data. (Set this to true if it should be ignored)
ยงExamples
use core::iter;
use core::result::Result;
use miniz_oxide::inflate::decompress_slice_iter_to_slice;
fn main() -> Result<(), ()> {
const ENCODED: [u8; 20] = [
120, 156, 243, 72, 205, 201, 201, 215, 81, 168, 202, 201, 76, 82, 4, 0, 27, 101, 4, 19,
];
let mut output = [0u8; 20];
// Using `once` to do the whole buffer in one go. One could also use e.g
// `slice::chunks` to easily split up a buffer into parts instead.
let result =
decompress_slice_iter_to_slice(&mut output, iter::once(ENCODED.as_slice()), true, false);
if let Ok(bytes) = result {
if output[..bytes] == b"Hello, zlib!"[..] {
return Ok(());
}
}
Err(())
}