Struct xz2::stream::Stream
[−]
[src]
pub struct Stream { /* fields omitted */ }
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.
Methods
impl Stream
[src]
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.
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 process
are Run
and Finish
. No kind
of flushing is supported, because the file format doesn't make it
possible.
fn new_stream_encoder(filters: &Filters, check: Check) -> Result<Stream, Error>
Initialize .xz Stream encoder using a custom filter chain
This function is similar to new_easy_encoder
but a custom filter chain
is specified.
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
,
TELL_IGNORE_CHECK
, or CONCATENATED
.
fn new_lzma_decoder(memlimit: u64) -> Result<Stream, Error>
Initialize a .lzma stream decoder.
The maximum memory usage can also be specified.
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.
fn process(&mut self,
input: &[u8],
output: &mut [u8],
action: Action)
-> Result<Status, Error>
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. Documentation for the
various action
arguments can be found on the respective variants.
fn process_vec(&mut self,
input: &[u8],
output: &mut Vec<u8>,
action: Action)
-> Result<Status, Error>
input: &[u8],
output: &mut Vec<u8>,
action: Action)
-> Result<Status, Error>
Performs the same data as 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.
fn total_in(&self) -> u64
Returns the total amount of input bytes consumed by this stream.
fn total_out(&self) -> u64
Returns the total amount of bytes produced by this stream.
fn memlimit(&self) -> u64
Get the current memory usage limit.
This is only supported if the underlying stream supports a memlimit.
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.