Given that I need to compress a huge file for HTTP download, instead of reading the whole file and compressing it in memory, I need to compress each chunk of the file and send chunk by chunk via HTTP response.
But the flate2 crate does not export API to access intermedia compression results, it just collects the output of each chunk and only finish() returns the final result. But how about OOM?
In fact, the zlib c library provides the interface to access the intermedia result.
I know I could use
Compress to compress buffer, but for gzip case, I need to write header and footer by hand, so I don't want to reinvent the wheel.