Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Seek / offset pointer in GzDecoder #310

Open
gwbres opened this issue Jul 26, 2022 · 4 comments
Open

Provide Seek / offset pointer in GzDecoder #310

gwbres opened this issue Jul 26, 2022 · 4 comments

Comments

@gwbres
Copy link

gwbres commented Jul 26, 2022

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 ?

@noonchen
Copy link

noonchen commented Oct 5, 2022

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

@milesj
Copy link

milesj commented Jun 1, 2023

Would also like to see this.

@hderms
Copy link

hderms commented Jun 2, 2023

I would also like to see this! Would be a game changer

@IriaSomobu
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants