-
Notifications
You must be signed in to change notification settings - Fork 29
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
Expose API for raw decoder primitives for LZMA and LZMA2. #74
Conversation
07055f4
to
ba2d082
Compare
src/lib.rs
Outdated
output.finish()?; | ||
let mut decoder = decode::lzma::LzmaDecoder::new(params, options.memlimit)?; | ||
|
||
decoder.decompress(input, output)?; |
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.
Decoding logic has been moved into LzmaDecoder::decompress
.
ba2d082
to
deb7a45
Compare
The current API for It might be worth looking into allowing reusage of a backing buffer in an A note, |
cc @gendx |
I encountered a situation where simply resetting the decoder state was not enough but since the decoder is being reused for each raw LZMA chunk, the unpacked size was also needed to be set. Since this might not be the case for every usage, I have it in I thought about exposing |
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.
Sorry for the delay, I just came back from holidays.
Overall this looks good, I just left a few nits.
Thank you a lot for contributing this!
1af381d
to
58155ef
Compare
c30bb38
to
e13c0fb
Compare
e13c0fb
to
8750cb0
Compare
I wanted to read an XZ file into decompressed chunks of some constant size. Currently I'm using xz_decompress. But Can I do read an XZ file as a sequence of decompressed byte chunks ( Thanks for creating this library! 😄 |
Pull Request Overview
This pull request fixes #72 by refactoring decoder functions to expose a zero-cost raw decoder API. The existing public API has been refactored to use the raw decoder API internally. The following additions to the public API become available with the
raw_decoder
feature enabled under thedecompress::raw
module.LzmaDecoder
LzmaDecoder::new(params: LzmaParams, memlimit: Option<usize>) -> Result<Self>
LzmaDecoder::reset(&mut self, unpacked_size: Option<Option<u64>>)
LzmaDecoder::decompress<'a, W: io::Write, R: io::BufRead>(&mut self, input: &mut R, output: &'a mut W)
Lzma2Decoder
Lzma2Decoder::new() -> Self
Lzma2Decoder::reset(&mut self)
Lzma2Decoder::decompress<'a, W: io::Write, R: io::BufRead>(&mut self, input: &mut R, output: &'a mut W)
LzmaProperties
LzmaParams
LzmaParams::new(properties: LzmaProperties, dict_size: u32, unpacked_size: Option<u64>) -> Self
LzmaParams:read_header<R>(input: &mut R, options: &Options) -> error::Result<LzmaParams>
raw_decoder
is enabled. I don't see any reason to restrict this to internal usage.Additionally, annotations have been added to indicate availability of APIs on docs.rs.

Testing Strategy
raw_decoder
APIs internally.