Frommi / miniz_oxide

Rust replacement for miniz
MIT License
168 stars 48 forks source link

Create a cleaner/easier API #103

Open oyvindln opened 3 years ago

oyvindln commented 3 years ago

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.

Lokathor commented 2 years ago

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>;