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.
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
Feat: Add zstd support #9
base: main
Are you sure you want to change the base?
Feat: Add zstd support #9
Changes from 3 commits
5ba458d
3344b98
6dd4d2d
ecfe4b6
7b35638
3be23f4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here about the
unwrap()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know enough about zstd compression, but I'm not sure just specifying
0
here (which appears to then use the default, level 3, compression) is the right thing to do, as it gives the user zero control.On the other hand, re-using the
compression
passed in above is problematic as gzip and zstd have very different compression level ranges (0-9 vs. -17 to 22), and introducing a new parameter toIo::new()
for zstd_level would be a breaking change.Thoughts @nh13?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like:
Not sure if it's the proper way to go about it but it's one possibility if it's preferred that the Io struct absolutely doesn't change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could see having a member per level, but then what about bzip2 and future compression levels? And perhaps we have compression that requires not just a level? And certainly we don't want to add translation layer that goes from 0-10 levels for each compression type.
What about instead of storing
compression
as a member ofIo
, we have a Map/Vec that stores a compression-specific struct (can impl a trait). You could even makeis_gzip_path
specific to the compression as a trait-level method (is_path_for
), so a new compression need only impl the base trait to be added. Then we avoid the if/else if/else chain there and it can just be a loop (with a default if it exits the loop)? Does that make sense?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. The
Io
struct probably will have to change at some point if further compression schemes are to be supported as far as I can see. #10 might also be a good solution to this. Haven't checked it out thoroughly yet, but it does feel like good idea to actually check the file format instead of just the extension, although might still want to have a way to compare the found format vs. extension to detect any inconsistencies.