pub enum CodecDecodeError<E> {
Decode {
source: E,
input_index: usize,
},
Incomplete {
input_index: usize,
required_total: usize,
available: usize,
},
TrailingInput {
consumed: usize,
remaining: usize,
},
InvalidInputIndex {
index: usize,
len: usize,
},
InvalidOutputIndex {
index: usize,
len: usize,
},
InsufficientOutput {
output_index: usize,
required: usize,
available: 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 failures that cannot be represented by the
wrapped codec itself, such as a value decoder receiving too few units before
it can safely call crate::Codec::decode or a buffered decoder
receiving an invalid output start index.
Variants§
Decode
The wrapped codec reported a decode error.
Fields
source: EError returned by the wrapped codec.
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.
Fields
InvalidInputIndex
The caller supplied an input index outside the input slice.
Fields
InvalidOutputIndex
The caller supplied an output index outside the output slice.
Fields
InsufficientOutput
The output slice cannot hold all output required by the adapter call.
Implementations§
Source§impl<E> CodecDecodeError<E>
impl<E> CodecDecodeError<E>
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 const fn invalid_input_index(index: usize, len: usize) -> Self
pub const fn invalid_input_index(index: usize, len: usize) -> Self
Sourcepub const fn invalid_output_index(index: usize, len: usize) -> Self
pub const fn invalid_output_index(index: usize, len: usize) -> Self
Sourcepub const fn insufficient_output(
output_index: usize,
required: usize,
available: usize,
) -> Self
pub const fn insufficient_output( output_index: usize, required: usize, available: usize, ) -> Self
Creates an insufficient-output error.
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_output_capacity(
output_len: usize,
output_index: usize,
required: usize,
) -> Result<(), Self>
pub fn ensure_output_capacity( output_len: usize, output_index: usize, required: usize, ) -> Result<(), Self>
Validates that an output slice can hold required adapter output.
§Parameters
output_len: Length of the output slice.output_index: Output index supplied by the caller.required: Output units required fromoutput_index.
§Returns
Returns Ok(()) when output capacity is sufficient.
§Errors
Returns an invalid-output-index error when output_index is beyond the
slice, or an insufficient-output error when fewer than required units
are writable from output_index.
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 ==.