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

Support for Seek trait #218

Closed
roman-holovin opened this issue Dec 9, 2019 · 3 comments
Closed

Support for Seek trait #218

roman-holovin opened this issue Dec 9, 2019 · 3 comments

Comments

@roman-holovin
Copy link

As far as I understand, Archive::skip is using read to skip over file contents.
Is it possible to require Read + Seek and use seek to move through the input?

@alexcrichton
Copy link
Owner

Thanks for the report! I originally had Read and Seek but preferred to only require Read. Ideally we'd use some form of specialization for using seek where we can, but unfortunately that's not easily done right now.

@roman-holovin
Copy link
Author

I originally had Read and Seek but preferred to only require Read

Can you describe reasoning or link the discussion? I would like to read that.

unfortunately that's not easily done right now.

Is there missing feature in compiler to do so? I've tried to modify slightly to require both Read and Seek, but it seems that is not something rustc can do now.

Can it be done with the separate API for now, while the common one is not available? And deprecate it latter.

fermeise added a commit to fermeise/tar-rs that referenced this issue Oct 4, 2021
`Archive::new` requires only `Read` for backward-compatibility, while
`Archive::new_from_seek` can be used with readers that also implement
`Seek`, to allow more efficient skipping over file contents.
@fermeise
Copy link
Contributor

fermeise commented Oct 4, 2021

In our project we have a use case where we need to read the metadata of a tar archive with large file entries (>10 GB). Adding support for Seek would allow us to reduce the runtime from minutes down to milliseconds.

I've added a PR with a proposal that adds support for readers that implement Seek while maintaining compatibility with readers that don't. Would you consider a change like this? Any alternative proposals?

fermeise added a commit to fermeise/tar-rs that referenced this issue Oct 5, 2021
`Archive::entries_with_seek` can be used to get an iterator over
entries for a reader that implements `Seek`.
fermeise added a commit to fermeise/tar-rs that referenced this issue Oct 5, 2021
`Archive::entries_with_seek` can be used to get an iterator over
entries for a reader that implements `Seek`.
fermeise added a commit to fermeise/tar-rs that referenced this issue Oct 6, 2021
`Archive::entries_with_seek` can be used to get an iterator over
entries for a reader that implements `Seek`.
alexcrichton pushed a commit that referenced this issue Oct 6, 2021
`Archive::entries_with_seek` can be used to get an iterator over
entries for a reader that implements `Seek`.
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

3 participants