Skip to main content

lzma_rust2/
stream.rs

1//! Types shared by every sans-I/O decoder in the crate.
2//!
3//! `LzmaStream`, `Lzma2Stream` and `XzStream` all expose the same push/pull
4//! shape: hand `process()` an input slice, an output slice and an [`Action`],
5//! and get back a [`StreamResult`].
6
7/// Action to perform during stream processing.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum Action {
10    /// Process available data without flushing.
11    Run,
12    /// Signal that no more input will be provided.
13    Finish,
14}
15
16/// Status returned by stream processing.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub enum Status {
19    /// More input or output space needed to continue.
20    Ok,
21    /// The stream has been fully processed.
22    StreamEnd,
23}
24
25/// Result of a single `process()` call.
26#[derive(Debug, Clone, Copy)]
27pub struct StreamResult {
28    /// Number of bytes consumed from the input buffer.
29    pub bytes_consumed: usize,
30    /// Number of bytes written to the output buffer.
31    pub bytes_produced: usize,
32    /// Current stream status.
33    pub status: Status,
34}