Frommi/miniz_oxide

Feature Request: decompress from input `Iterator` to output `Iterator` (for low RAM usage in embedded Rust)

Opened this issue · 2 comments

Hi,

Feel free to point me in the right direction if this is supported just now (or is implemented in another crate I've not found yet), but what I'm looking for is a function with an input similar to decompress_slice_iter_to_slice but that returns an iterator I can iterate over to get decompressed data. I'm trying to run on RAM constrained devices in no_std, eventually reading image files and writing pixels directly to the display.

Ideally, and I might be far off here from how it'd actually need to work:

  • the decompress_* function gets called & is given an Iterator that returns u8s
  • it returns a struct implementing core::iter::Iterator over u8s
  • calling next() on the returned iter will fill a (small) internal buffer by calling the input Iterator, decompressing, then transparently returning values from the output buffer until it's consumed, refilling it as needed

Ideally the size of the internal buffer would be definable by the user (const generic?, heapless does something similar) within whatever bounds make sense.

This is potentially related to #25 but more targeted towards resource-constrained devices (embedded Rust etc)

Yeah it seems reasonable to have something like this for cases where flate2 is too heavy. I've not personally done much work on this library in quite a while, might look into it at some point if no one else starts tinkering with it but might take a while.

I'm still thinking about this one occasionally - I think it'd be fairly easy/nice to do with a generator which'll be available in the 2024 edition. Since iterator in / iterator out things should become really neat with generators.

I'll probably have free some time at the end of the year to look into it, unless anyone else wants to.
(Which'll align with the 2024 edition's planned release in early 2025)