This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
ZipArchive::by_name_seek
function which returns aZipFileSeek
structure that implementsSeek
.This only works for
Stored
types of zips for now, although I'm sure this can be implemented for compressed archives as well using some kind of lazy indexing structure that helps map compressed indexes to uncompressed ones quickly.I tried various ways of adding this feature, but I could only make it work like this. I "forked" the
ZipFile
structure, added aZipFileSeek
, and added a common trait that implements the metadata goodies. The reason I couldn't make it work with a unified approach is because the current library supports non-Seek
base readers, and there's no such thing as a dynamic cast in Rust (nor would I want there to be).One consequence of the trait is that this change became API breaking, as the trait must be imported to access the metadata functions. I can add back the original functions that dispatches to the trait in case this is an issue.
Although I have not added tests to this crate, it has been tested fairly thoroughly with tests testing our own usage of the feature.