XzDecoder

Struct XzDecoder 

Source
pub struct XzDecoder<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> XzDecoder<'a>

Source

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.

Source

pub fn with_alloc_dict_size( initial_dict: usize, max_dict: usize, ) -> XzDecoder<'static>

Source

pub fn with_alloc_dict( initial_dict: Vec<u8>, max_dict: usize, ) -> XzDecoder<'static>

Source

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.

Source

pub fn in_heap_with_alloc_dict_size( initial_dict: usize, max_dict: usize, ) -> Box<XzDecoder<'static>>

Source

pub fn in_heap_with_alloc_dict( initial_dict: Vec<u8>, max_dict: usize, ) -> Box<XzDecoder<'static>>

Source

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
Source

pub const fn reset(&mut self)

Reset the decoder

Trait Implementations§

Source§

impl<'a> Debug for XzDecoder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for XzDecoder<'static>

Available on crate feature alloc only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for XzDecoder<'a>

§

impl<'a> RefUnwindSafe for XzDecoder<'a>

§

impl<'a> Send for XzDecoder<'a>

§

impl<'a> Sync for XzDecoder<'a>

§

impl<'a> Unpin for XzDecoder<'a>

§

impl<'a> !UnwindSafe for XzDecoder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.