pub enum CodecDecodeError<E> {
Decode {
source: E,
input_index: usize,
},
DecodeReset {
source: E,
},
DecodeFlush {
source: E,
},
Incomplete {
input_index: usize,
required_total: usize,
available: usize,
},
TrailingInput {
consumed: usize,
remaining: usize,
},
}Expand description
Error reported by codec-backed value and buffered decoder adapters.
The wrapped codec remains responsible for domain-specific decode failures.
This type adds adapter-level domain failures that cannot be represented by
the wrapped codec itself, such as closed-input incomplete values and
trailing units in exact-value decodes. Buffer index and capacity failures
are represented by crate::TranscodeError.
Variants§
Decode
The wrapped codec reported a decode error.
Fields
source: EError returned by the wrapped codec.
DecodeReset
The wrapped codec reported an error while resetting decode state.
Fields
source: EError returned by crate::Codec::decode_reset.
DecodeFlush
The wrapped codec reported an error while flushing decode state.
Fields
source: EError returned by crate::Codec::decode_flush.
Incomplete
The adapter could not safely call the wrapped codec because input ended.
Fields
TrailingInput
A whole-value decode succeeded but left trailing input units.
Implementations§
Source§impl<E> CodecDecodeError<E>
impl<E> CodecDecodeError<E>
Sourcepub const fn decode_reset(source: E) -> Self
pub const fn decode_reset(source: E) -> Self
Creates an error wrapping a codec-specific decode-reset error.
§Parameters
source: Error returned bycrate::Codec::decode_reset.
§Returns
Returns a codec decode-reset error wrapper.
Sourcepub const fn decode_flush(source: E) -> Self
pub const fn decode_flush(source: E) -> Self
Creates an error wrapping a codec-specific decode-flush error.
§Parameters
source: Error returned bycrate::Codec::decode_flush.
§Returns
Returns a codec decode-flush error wrapper.
Sourcepub const fn incomplete(
input_index: usize,
required_total: usize,
available: usize,
) -> Self
pub const fn incomplete( input_index: usize, required_total: usize, available: usize, ) -> Self
Sourcepub const fn trailing_input(consumed: usize, remaining: usize) -> Self
pub const fn trailing_input(consumed: usize, remaining: usize) -> Self
Sourcepub fn into_source(self) -> Option<E>
pub fn into_source(self) -> Option<E>
Extracts the wrapped codec source error, when this variant has one.
§Returns
Returns Some(source) for codec decode, reset, and flush failures.
Returns None for adapter-only failures.
Sourcepub const fn is_incomplete(&self) -> bool
pub const fn is_incomplete(&self) -> bool
Returns whether this error indicates an incomplete input prefix.
§Returns
Returns true only for the Incomplete variant.
Sourcepub fn needed_additional(&self) -> Option<NonZeroUsize>
pub fn needed_additional(&self) -> Option<NonZeroUsize>
Returns the additional input units needed to make progress.
This is a convenience accessor over the Incomplete
variant’s fields. Streaming callers can use it to determine how many
more units they must buffer before retrying a decode.
§Returns
Returns Some(needed) for Incomplete errors,
where needed is the strictly positive difference between the minimum
units required and those already available. Returns None for all
other variants.
Sourcepub fn ensure_min_input(
input_len: usize,
input_index: usize,
min_required: usize,
) -> Result<(), Self>
pub fn ensure_min_input( input_len: usize, input_index: usize, min_required: usize, ) -> Result<(), Self>
Validates that enough input units are available from input_index.
§Parameters
input_len: Length of the input slice.input_index: Absolute input index where reading starts.min_required: Minimum units required frominput_index.
§Returns
Returns Ok(()) when at least min_required units are available.
§Errors
Returns an incomplete-input error when fewer than min_required units
are available from input_index.
Trait Implementations§
Source§impl<E: Clone> Clone for CodecDecodeError<E>
impl<E: Clone> Clone for CodecDecodeError<E>
Source§fn clone(&self) -> CodecDecodeError<E>
fn clone(&self) -> CodecDecodeError<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<E: Copy> Copy for CodecDecodeError<E>
Source§impl<E: Debug> Debug for CodecDecodeError<E>
impl<E: Debug> Debug for CodecDecodeError<E>
Source§impl<E> Display for CodecDecodeError<E>where
E: Display,
impl<E> Display for CodecDecodeError<E>where
E: Display,
impl<E: Eq> Eq for CodecDecodeError<E>
Source§impl<E> Error for CodecDecodeError<E>
impl<E> Error for CodecDecodeError<E>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E: Hash> Hash for CodecDecodeError<E>
impl<E: Hash> Hash for CodecDecodeError<E>
Source§impl<E: PartialEq> PartialEq for CodecDecodeError<E>
impl<E: PartialEq> PartialEq for CodecDecodeError<E>
Source§fn eq(&self, other: &CodecDecodeError<E>) -> bool
fn eq(&self, other: &CodecDecodeError<E>) -> bool
self and other values to be equal, and is used by ==.