flate2-rs
flate2-rs copied to clipboard
Provide Seek / offset pointer in GzDecoder
Hello,
I would like to enhance the GzDecoder with the std::io::Seek trait and std::io::rewind() capacities, to rewind the file although we might already have uncompressed some data. Is that even doable ?
My first basic attempt here, I implement the Seek trait. Let's say I uncompressed a first line, then call Seek(pos=0) to rewind, the first line is forever lost and cannot be uncompressed a second time.
My second attempt here I try to implement something that would rewind right after the .gz header (that we would never read again) and try to reset the FSM at the beginning of the file Body. Same results, it's like none of the things I do have an impact. I guess I'm missing some important attributes to reset, but I'm having a hard time understanding the code.
Any advice ?
I'd like to request this feature as well.
zlib.h already contains related functions:
https://github.com/madler/zlib/blob/21767c654d31d2dccdde4330529775c6c5fd5389/zlib.h#L1849-L1863
Would also like to see this.
I would also like to see this! Would be a game changer
To anyone looking for a solution: in case you really need Seek and you dont mind RAM overhead -- you can use SeekableReader. It is Read + Seek wrapper around Read that caches read data within internal buffer.