xz2::stream

Enum Action

Source
pub enum Action {
    Run = 0,
    SyncFlush = 1,
    FullFlush = 2,
    FullBarrier = 4,
    Finish = 3,
}
Expand description

The action argument for process,

After the first use of SyncFlush, FullFlush, FullBarrier, or Finish, the same action' must is used until processreturnsStatus::StreamEnd. Also, the amount of input must not be modified by the application until processreturnsStatus::StreamEnd. Changing the action’ or modifying the amount of input will make process return Error::Program.

Variants§

§

Run = 0

Continue processing

When encoding, encode as much input as possible. Some internal buffering will probably be done (depends on the filter chain in use), which causes latency: the input used won’t usually be decodeable from the output of the same process call.

When decoding, decode as much input as possible and produce as much output as possible.

§

SyncFlush = 1

Make all the input available at output

Normally the encoder introduces some latency. SyncFlush forces all the buffered data to be available at output without resetting the internal state of the encoder. This way it is possible to use compressed stream for example for communication over network.

Only some filters support SyncFlush. Trying to use SyncFlush with filters that don’t support it will make process return Error::Options. For example, LZMA1 doesn’t support SyncFlush but LZMA2 does.

Using SyncFlush very often can dramatically reduce the compression ratio. With some filters (for example, LZMA2), fine-tuning the compression options may help mitigate this problem significantly (for example, match finder with LZMA2).

Decoders don’t support SyncFlush.

§

FullFlush = 2

Finish encoding of the current block.

All the input data going to the current block must have been given to the encoder. Call process with FullFlush until it returns Status::StreamEnd. Then continue normally with Run or finish the Stream with Finish.

This action is currently supported only by stream encoder and easy encoder (which uses stream encoder). If there is no unfinished block, no empty block is created.

§

FullBarrier = 4

Finish encoding of the current block.

This is like FullFlush except that this doesn’t necessarily wait until all the input has been made available via the output buffer. That is, process might return Status::StreamEnd as soon as all the input has been consumed.

FullBarrier is useful with a threaded encoder if one wants to split the .xz Stream into blocks at specific offsets but doesn’t care if the output isn’t flushed immediately. Using FullBarrier allows keeping the threads busy while FullFlush would make process wait until all the threads have finished until more data could be passed to the encoder.

With a Stream initialized with the single-threaded new_stream_encoder or new_easy_encoder, FullBarrier is an alias for FullFlush.

§

Finish = 3

Finish the current operation

All the input data must have been given to the encoder (the last bytes can still be pending in next_in). Call process with Finish until it returns Status::StreamEnd. Once Finish has been used, the amount of input must no longer be changed by the application.

When decoding, using Finish is optional unless the concatenated flag was used when the decoder was initialized. When concatenated was not used, the only effect of Finish is that the amount of input must not be changed just like in the encoder.

Trait Implementations§

Source§

impl Clone for Action

Source§

fn clone(&self) -> Action

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Action

Auto Trait Implementations§

§

impl Freeze for Action

§

impl RefUnwindSafe for Action

§

impl Send for Action

§

impl Sync for Action

§

impl Unpin for Action

§

impl UnwindSafe for Action

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.