Expose API for raw decoder primitives for LZMA and LZMA2.#74
Expose API for raw decoder primitives for LZMA and LZMA2.#74gendx merged 2 commits intogendx:masterfrom
Conversation
07055f4 to
ba2d082
Compare
| output.finish()?; | ||
| let mut decoder = decode::lzma::LzmaDecoder::new(params, options.memlimit)?; | ||
|
|
||
| decoder.decompress(input, output)?; |
There was a problem hiding this comment.
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 |
gendx
left a comment
There was a problem hiding this comment.
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_decoderfeature enabled under thedecompress::rawmodule.LzmaDecoderLzmaDecoder::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)Lzma2DecoderLzma2Decoder::new() -> SelfLzma2Decoder::reset(&mut self)Lzma2Decoder::decompress<'a, W: io::Write, R: io::BufRead>(&mut self, input: &mut R, output: &'a mut W)LzmaPropertiesLzmaParamsLzmaParams::new(properties: LzmaProperties, dict_size: u32, unpacked_size: Option<u64>) -> SelfLzmaParams:read_header<R>(input: &mut R, options: &Options) -> error::Result<LzmaParams>raw_decoderis 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_decoderAPIs internally.