Skip to main content

qubit_codec/transcode/engine/
decode_incomplete_action.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Incomplete-decode actions returned by buffered decoder policy hooks.
9
10use crate::Codec;
11
12/// Incomplete-decode action for a codec-backed decode hook.
13pub type DecodeIncompleteActionOf<C> = DecodeIncompleteAction<<C as Codec>::Value>;
14
15/// Action selected after end-of-input leaves a codec value incomplete.
16///
17/// The decode engine invokes this action only after the caller has established
18/// EOF. A non-rejecting action consumes every source unit still available from
19/// the current decode cursor.
20///
21/// # Type Parameters
22///
23/// - `Value`: Decoded output value type.
24#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
25#[non_exhaustive]
26pub enum DecodeIncompleteAction<Value> {
27    /// Reject the incomplete source tail.
28    ///
29    /// The decode engine reports the codec-domain error when available, or an
30    /// [`crate::TranscodeFailure::IncompleteInput`] framework error otherwise.
31    Reject,
32
33    /// Consume the entire incomplete source tail without output.
34    Skip,
35
36    /// Consume the entire incomplete source tail and emit one replacement.
37    Emit {
38        /// Replacement value to write to the output buffer.
39        value: Value,
40    },
41}