pub enum TranscodeDomainError<E> {
Reset {
source: E,
},
Main {
source: E,
input_index: usize,
input_consumed: Option<NonZeroUsize>,
},
Finish {
source: E,
},
}Expand description
Domain-specific codec, charset, or policy error with transcode context.
Reset and finish failures are lifecycle failures and therefore cannot carry an input index. Main-phase failures always carry the absolute input index where the domain error occurred.
§Type Parameters
E: Domain error reported by the concrete codec, hook, or facade.
§Examples
use qubit_codec::TranscodeDomainError;
let error = TranscodeDomainError::main("invalid byte", 4);
assert_eq!(error.input_index(), Some(4));
assert_eq!(error.to_string(), "codec main error at input index 4: invalid byte");Variants§
Reset
Domain error reported while resetting codec or hook state.
Fields
source: EDomain error returned by the codec or policy facade.
Main
Domain error reported while processing input.
Fields
source: EDomain error returned by the codec or policy facade.
input_consumed: Option<NonZeroUsize>Invalid input units consumed by the codec-domain error, when known.
Finish
Domain error reported while finishing codec or hook state.
Fields
source: EDomain error returned by the codec or policy facade.
Implementations§
Source§impl<E> TranscodeDomainError<E>
impl<E> TranscodeDomainError<E>
Sourcepub const fn main_with_consumed(
source: E,
input_index: usize,
input_consumed: Option<NonZeroUsize>,
) -> Self
pub const fn main_with_consumed( source: E, input_index: usize, input_consumed: Option<NonZeroUsize>, ) -> Self
Creates a main-phase domain error with decode consumption context.
§Parameters
source: Domain error returned by value processing.input_index: Absolute input index where the error occurred.input_consumed: Invalid input units consumed, when known.
§Returns
Returns a main-phase domain error with consumption context.
Sourcepub fn into_source(self) -> E
pub fn into_source(self) -> E
Sourcepub const fn input_index(&self) -> Option<usize>
pub const fn input_index(&self) -> Option<usize>
Returns the absolute input index associated with the error.
§Returns
Returns Some(index) for main-phase errors and None for reset or
finish errors.
Sourcepub const fn input_consumed(&self) -> Option<NonZeroUsize>
pub const fn input_consumed(&self) -> Option<NonZeroUsize>
Returns invalid input consumption associated with the error.
§Returns
Returns Some(consumed) when a main-phase decode error reports the
invalid input width. Returns None otherwise.
Sourcepub fn map_source<T, F>(self, f: F) -> TranscodeDomainError<T>where
F: FnOnce(E) -> T,
pub fn map_source<T, F>(self, f: F) -> TranscodeDomainError<T>where
F: FnOnce(E) -> T,
Trait Implementations§
Source§impl<E: Clone> Clone for TranscodeDomainError<E>
impl<E: Clone> Clone for TranscodeDomainError<E>
impl<E: Copy> Copy for TranscodeDomainError<E>
Source§impl<E: Debug> Debug for TranscodeDomainError<E>
impl<E: Debug> Debug for TranscodeDomainError<E>
Source§impl<E> Display for TranscodeDomainError<E>where
E: Display,
impl<E> Display for TranscodeDomainError<E>where
E: Display,
impl<E: Eq> Eq for TranscodeDomainError<E>
Source§impl<E> Error for TranscodeDomainError<E>
impl<E> Error for TranscodeDomainError<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()