pub enum Action {
    Run,
    SyncFlush,
    FullFlush,
    FullBarrier,
    Finish,
}
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

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

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

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.