luizirber / niffler

Simple and transparent support for compressed files.
Apache License 2.0
75 stars 7 forks source link

Support BufRead interfaces #51

Closed dralley closed 2 years ago

dralley commented 2 years ago

It's always a great idea to have BufReader around IO handles such as files. Unfortunately if you have one underneath Niffler, it gets erased by Box<dyn Read>, and if you have another API on top of that which requires BufRead such as quick_xml::Reader, you need to add another BufReader on the outside as well.

It looks like the underlying compression libraries (xz, flate, bz2, I'm not sure about zstd-rs?) support BufRead interfaces and it would be great if it could be passed through.

https://docs.rs/flate2/1.0.22/flate2/bufread/index.html https://docs.rs/bzip2/latest/bzip2/bufread/index.html https://docs.rs/xz/0.1.0/xz/bufread/index.html https://docs.rs/zstd/0.9.0+zstd.1.5.0/zstd/stream/read/struct.Decoder.html

dralley commented 2 years ago

I misunderstood which side of the equation the "BufRead" applied to