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
processreturns
Status::StreamEnd. Also, the amount of input must not be modified by the application until
processreturns
Status::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.