Frommi/miniz_oxide

Create a cleaner/easier API

Opened this issue · 1 comments

The current API was strung together to first sit under the miniz-compatible C API, and modified slightly later to avoid going via C and unsafe for the flate2 front-end. Other than the simple functions that do all in one the api is rather clunky to use. For most users using flate2 with this as backend is probably fine, but it would be nice to have something a bit more clean for people that want more control.

Looking for some suggestions on how to structure this.

One thing I've wanted for PNG parsing is a way to decompress a series of slices into a single output slice. In this case, the output size will already be known from the PNG header, and a sufficiently sized slice can be provided to the library (or error if an overflow would occur because the header and the image data don't agree).

So the function signature that I'm looking for is something like this:

pub fn decompress_slices(target: &mut [u8], slices: impl Iterator<Item = &[u8]>) -> Result<(), DecompressionError>;