rust-lang / flate2-rs

DEFLATE, gzip, and zlib bindings for Rust
https://docs.rs/flate2
Apache License 2.0
862 stars 159 forks source link

Implement BufRead/Write for en/decoders alongside Read/Write #384

Closed chernoivanenkoofficial closed 7 months ago

chernoivanenkoofficial commented 7 months ago

Hello.

Have been using deflate for encoding/decoding various moderatly sized data (under 5KB), where I need to parse some encoded heading variabely-sized metadata first.

Have been wondering, if there is any strong reason as to why encoders and decoders do not implement BufRead/Write, if internal implementations certainly use buffered IO.

Even though files in question are small, they can quickly bloat in numbers, and the neccessity of repeatedly either allocating in-memory raw buffers on heap or wrapping decoder/incoder in BufReaders/Writers (which, while enabling more "lazy", "stream-fashioned" approach, still do those same allocations internally) seems concerning perfromance-wise.