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

total_in(&self) / total_out(&self) implementation for GzDecoder / GzEncoder / MultiGzDecoder #381

Open fedy-cz opened 8 months ago

fedy-cz commented 8 months ago

Hello

Is there a reason why total_in(&self) / total_out(&self) isn't implemented for Gzip decoders/encoders? It is present for both Zlib and Deflate and could be really useful for monitoring progress of the operation.

Looking at the decoder implementations, they seem to be using the same DeflateDecoder underneath - only wrapped in CrcReader<>. So it could be as simple as forwarding the function call in.

It could be also nice to separate these functions into a trait to provide a generic interface for libraries building on top of flate2.

Byron commented 8 months ago

Thanks for bringing this up!

Even though I don't have an answer, I wonder if that could be an oversight that could be remedied by adding these methods and wiring them up? Could that work as 'as simple as possible' solution? And possible, do we have tests that could be extended to use that new functionality?

fedy-cz commented 8 months ago

Submited PR for this: https://github.com/rust-lang/flate2-rs/pull/382