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> =
14 DecodeIncompleteAction<<C as Codec>::Value>;
15
16/// Action selected after end-of-input leaves a codec value incomplete.
17///
18/// The decode engine invokes this action only after the caller has established
19/// EOF. A non-rejecting action consumes every source unit still available from
20/// the current decode cursor.
21///
22/// # Type Parameters
23///
24/// - `Value`: Decoded output value type.
25#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
26#[non_exhaustive]
27pub enum DecodeIncompleteAction<Value> {
28 /// Reject the incomplete source tail.
29 ///
30 /// The decode engine reports the codec-domain error when available, or an
31 /// [`crate::TranscodeFailure::IncompleteInput`] framework error otherwise.
32 Reject,
33
34 /// Consume the entire incomplete source tail without output.
35 Skip,
36
37 /// Consume the entire incomplete source tail and emit one replacement.
38 Emit {
39 /// Replacement value to write to the output buffer.
40 value: Value,
41 },
42}