I needed this in one of my projects and decided I'd better contribute upstream than hand-roll it. It's a common use case for handling untrusted data that may contain decompression bombs. Using the lower-level interface for this is quite complicated, as illustrated by this very function. People typically go through flate2 for this, but even then it's kinda awkward.
We're starting to see signs of combinatorial explosion here, so I'm open to making this into a builder pattern if you prefer.
I needed this in one of my projects and decided I'd better contribute upstream than hand-roll it. It's a common use case for handling untrusted data that may contain decompression bombs. Using the lower-level interface for this is quite complicated, as illustrated by this very function. People typically go through
flate2
for this, but even then it's kinda awkward.We're starting to see signs of combinatorial explosion here, so I'm open to making this into a builder pattern if you prefer.