pub struct Stream { /* private fields */ }Expand description
Representation of an in-memory LZMA encoding or decoding stream.
Wraps the raw underlying lzma_stream type and provides the ability to
create streams which can either decode or encode various LZMA-based formats.
Implementations§
Source§impl Stream
Encoder-related functions
 
impl Stream
Encoder-related functions
Sourcepub fn new_easy_encoder(preset: u32, check: Check) -> Result<Stream, Error>
 
pub fn new_easy_encoder(preset: u32, check: Check) -> Result<Stream, Error>
Initialize .xz stream encoder using a preset number
This is intended to be used by most for encoding data. The preset
argument is a number 0-9 indicating the compression level to use, and
normally 6 is a reasonable default.
The check argument is the integrity check to insert at the end of the
stream. The default of Crc64 is typically appropriate.
Sourcepub fn new_lzma_encoder(options: &LzmaOptions) -> Result<Stream, Error>
 
pub fn new_lzma_encoder(options: &LzmaOptions) -> Result<Stream, Error>
Initialize .lzma encoder (legacy file format)
The .lzma format is sometimes called the LZMA_Alone format, which is the reason for the name of this function. The .lzma format supports only the LZMA1 filter. There is no support for integrity checks like CRC32.
Use this function if and only if you need to create files readable by
legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
(the new_easy_encoder function) is strongly recommended.
The valid action values for Stream::process are Action::Run and Action::Finish.
No flushing is supported, because the file format doesn’t support it.
Source§impl Stream
Decoder-related functions
 
impl Stream
Decoder-related functions
Sourcepub fn new_auto_decoder(memlimit: u64, flags: u32) -> Result<Stream, Error>
 
pub fn new_auto_decoder(memlimit: u64, flags: u32) -> Result<Stream, Error>
Initialize a decoder which will choose a stream/lzma formats depending on the input stream.
Sourcepub fn new_stream_decoder(memlimit: u64, flags: u32) -> Result<Stream, Error>
 
pub fn new_stream_decoder(memlimit: u64, flags: u32) -> Result<Stream, Error>
Initialize a .xz stream decoder.
The maximum memory usage can be specified along with flags such as
TELL_ANY_CHECK, TELL_NO_CHECK, TELL_UNSUPPORTED_CHECK,
IGNORE_CHECK, or CONCATENATED.
Sourcepub fn new_lzma_decoder(memlimit: u64) -> Result<Stream, Error>
 
pub fn new_lzma_decoder(memlimit: u64) -> Result<Stream, Error>
Initialize a .lzma stream decoder.
The maximum memory usage can also be specified.
Source§impl Stream
Generic functions
 
impl Stream
Generic functions
Sourcepub fn process(
    &mut self,
    input: &[u8],
    output: &mut [u8],
    action: Action,
) -> Result<Status, Error>
 
pub fn process( &mut self, input: &[u8], output: &mut [u8], action: Action, ) -> Result<Status, Error>
Processes some data from input into an output buffer.
This will perform the appropriate encoding or decoding operation
depending on the kind of underlying stream. See Action for the
possible actions that can be taken.
After the first use of Action::SyncFlush, Action::FullFlush,
Action::FullBarrier, or Action::Finish, the same Action
must be used until this returns Status::StreamEnd. Not doing so
will result in a Error::Program.
The amount of input must not be modified by the application until
this returns Status::StreamEnd, otherwise Error::Program will
be returned.
Sourcepub fn process_uninit(
    &mut self,
    input: &[u8],
    output: &mut [MaybeUninit<u8>],
    action: Action,
) -> Result<Status, Error>
 
pub fn process_uninit( &mut self, input: &[u8], output: &mut [MaybeUninit<u8>], action: Action, ) -> Result<Status, Error>
Same as Self::process but accepts uninitialized buffer.
To retrieve bytes written into the output, please call Self::total_out() before
and after the call to Self::process_uninit and the diff of total_out would be
the bytes written to the output.
Sourcepub fn process_vec(
    &mut self,
    input: &[u8],
    output: &mut Vec<u8>,
    action: Action,
) -> Result<Status, Error>
 
pub fn process_vec( &mut self, input: &[u8], output: &mut Vec<u8>, action: Action, ) -> Result<Status, Error>
Performs the same data as Stream::process, but places output data in a Vec.
This function will use the extra capacity of output as a destination
for bytes to be placed. The length of output will automatically get
updated after the operation has completed.
See Stream::process for the other arguments.
Sourcepub fn memlimit(&self) -> u64
 
pub fn memlimit(&self) -> u64
Get the current memory usage limit.
This is only supported if the underlying stream supports a memlimit.
Sourcepub fn set_memlimit(&mut self, limit: u64) -> Result<(), Error>
 
pub fn set_memlimit(&mut self, limit: u64) -> Result<(), Error>
Set the current memory usage limit.
This can return Error::MemLimit if the new limit is too small or
Error::Program if this stream doesn’t take a memory limit.