#[non_exhaustive]pub enum DecodeInvalidAction<Value> {
Reject,
Skip {
consumed: NonZeroUsize,
},
Emit {
value: Value,
consumed: NonZeroUsize,
},
}Expand description
Action selected after a codec reports invalid encoded input.
While the stream is open, incomplete input is not an invalid-input policy
action. Codecs report it with crate::DecodeFailure::Incomplete, and the
decode engine converts it into crate::TranscodeStatus::NeedInput. After
upstream EOF, crate::Transcoder::transcode_eof asks the codec to resolve
a trailing incomplete sequence through crate::Codec::decode_eof; if it
remains incomplete, the engine calls
crate::engine::DecodeIncompleteAction through
crate::engine::TranscodeDecodeHooks::handle_incomplete_decode.
§Type Parameters
Value: Decoded output value type.
§Examples
use core::num::NonZeroUsize;
use qubit_codec::engine::DecodeInvalidAction;
let action = DecodeInvalidAction::<u8>::Skip {
consumed: NonZeroUsize::new(1).unwrap(),
};
assert!(matches!(action, DecodeInvalidAction::Skip { .. }));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Reject
Reject the current invalid input.
The decode engine reports the original codec decode error as
crate::TranscodeDecodeError::Domain at the current input index.
Skip
Consume invalid input without producing output.
consumed must not exceed the hook context’s available input count.
Over-consuming is a hook contract violation and panics in the engine.
Fields
consumed: NonZeroUsizeSource units to consume.
Emit
Produce one replacement value and consume source units.
consumed must not exceed the hook context’s available input count.
Over-consuming is a hook contract violation and panics in the engine.
Fields
value: ValueValue to write to the output buffer.
consumed: NonZeroUsizeSource units to consume.