pub struct XzDecoder<'a> { /* private fields */ }Implementations§
Source§impl<'a> XzDecoder<'a>
impl<'a> XzDecoder<'a>
Sourcepub fn with_fixed_size_dict(dict: &'a mut [u8]) -> Self
pub fn with_fixed_size_dict(dict: &'a mut [u8]) -> Self
Creates a new xz decoder that uses a fixed size dictionary. The content in the dict slice is irrelevant and will be overwritten.
pub fn with_alloc_dict_size( initial_dict: usize, max_dict: usize, ) -> XzDecoder<'static>
pub fn with_alloc_dict( initial_dict: Vec<u8>, max_dict: usize, ) -> XzDecoder<'static>
Sourcepub fn in_heap() -> Box<XzDecoder<'static>>
pub fn in_heap() -> Box<XzDecoder<'static>>
This allocates a XzDecoder in heap.
The default dictionary buffer of 8MB will be allocated additionally.
8MB is the default value used by lzma-utils to create
.xz files if no other option is passed to the xz program.
The maximum dictionary size the decoder will allocate (should the input file require it) is 3GB.
pub fn in_heap_with_alloc_dict_size( initial_dict: usize, max_dict: usize, ) -> Box<XzDecoder<'static>>
pub fn in_heap_with_alloc_dict( initial_dict: Vec<u8>, max_dict: usize, ) -> Box<XzDecoder<'static>>
Sourcepub fn decode(
&mut self,
input_data: &[u8],
output_data: &mut [u8],
) -> Result<XzNextBlockResult, XzError>
pub fn decode( &mut self, input_data: &[u8], output_data: &mut [u8], ) -> Result<XzNextBlockResult, XzError>
Processes the next block of input data and possibly produces output.
The recommended minimum size of the output buffer is 256 bytes, the larger, the better. The input buffer should also be at least that size, the larger, the better. However, obviously, at the end of the stream this is not possible/needed.
The decoder can be reused to decode multiple xz streams if “reset”
is called after XzNextBlockResult::EndOfStream was returned.
Failure to do so will lead to Err XzError::NeedsReset upon future calls.
This implementation will NOT parse the padding 0 bytes mentioned in the XZ documentation that occur between concatenated streams of two xz files. The caller will have to skip all 0 bytes between such streams.
§Errors
Most errors returned by this fn are fatal and the decoder must be reset afterward.
If decode is called again when the decoder had a fatal error then it will cause an Err with XzError::NeedsReset.
The only errors that are not fatal are:
XzError::NeedsLargerInputBuffer- Input buffer does not contain enough data to make progress