pub enum TranscodeDecodeError<E> {
Failure(TranscodeFailure),
Domain(TranscodeDomainError<E>),
}Expand description
Error reported by a decode-oriented transcode operation.
§Type Parameters
E: Owned codec or policy failure preserved with transcode context.
§Examples
use qubit_codec::TranscodeDecodeError;
let error = TranscodeDecodeError::domain_main("invalid byte", 3);
assert!(error.is_domain());
assert_eq!(error.domain_ref(), Some(&"invalid byte"));
assert!(error.failure_ref().is_none());Variants§
Failure(TranscodeFailure)
Framework-level transcode failure.
Tuple Fields
0: TranscodeFailureFramework contract, capacity, or incomplete-input failure.
Domain(TranscodeDomainError<E>)
Domain-specific codec, charset, or policy error.
Tuple Fields
0: TranscodeDomainError<E>Codec failure retaining its phase and source position.
Implementations§
Source§impl<E> TranscodeDecodeError<E>
impl<E> TranscodeDecodeError<E>
Sourcepub const fn domain_reset(source: E) -> Self
pub const fn domain_reset(source: E) -> Self
Sourcepub const fn domain_main(source: E, input_index: usize) -> Self
pub const fn domain_main(source: E, input_index: usize) -> Self
Sourcepub const fn domain_main_with_consumed(
source: E,
input_index: usize,
input_consumed: Option<NonZeroUsize>,
) -> Self
pub const fn domain_main_with_consumed( source: E, input_index: usize, input_consumed: Option<NonZeroUsize>, ) -> Self
Creates a main-phase domain-specific transcode error with decode consumption context.
§Parameters
source: Owned codec or policy failure.input_index: Absolute position of the failing input.input_consumed: Some(non-zero span) when known, or None for an unknown span.
§Returns
The main-phase failure retaining the known or unknown consumed span.
Sourcepub const fn domain_finish(source: E) -> Self
pub const fn domain_finish(source: E) -> Self
Sourcepub fn from_decode_failure(
failure: DecodeFailure<E>,
input_index: usize,
available: usize,
) -> Self
pub fn from_decode_failure( failure: DecodeFailure<E>, input_index: usize, available: usize, ) -> Self
Converts a low-level decode failure into a decode transcode error.
§Parameters
failure: Owned incomplete or invalid low-level failure.input_index: Absolute failing input position.available: Number of readable units at that position.
§Returns
A domain error when a codec source exists; otherwise an incomplete-input framework failure.
Sourcepub const fn is_domain(&self) -> bool
pub const fn is_domain(&self) -> bool
Returns whether this error wraps a domain error.
§Returns
True for Domain and false for a framework Failure.
Sourcepub const fn failure_ref(&self) -> Option<&TranscodeFailure>
pub const fn failure_ref(&self) -> Option<&TranscodeFailure>
Returns the framework failure carried by this error.
§Returns
Some(borrowed failure) for Failure, or None for Domain.
Sourcepub const fn domain_error_ref(&self) -> Option<&TranscodeDomainError<E>>
pub const fn domain_error_ref(&self) -> Option<&TranscodeDomainError<E>>
Borrows the wrapped domain error and transcode context.
§Returns
Some(borrowed context) for Domain, or None for Failure.
Sourcepub const fn domain_ref(&self) -> Option<&E>
pub const fn domain_ref(&self) -> Option<&E>
Sourcepub fn map_domain<F, T>(self, f: F) -> TranscodeDecodeError<T>where
F: FnOnce(E) -> T,
pub fn map_domain<F, T>(self, f: F) -> TranscodeDecodeError<T>where
F: FnOnce(E) -> T,
Maps the wrapped domain error while preserving framework failures.
§Type Parameters
F: One-shot mapping closure, invoked only for a domain failure.T: Replacement domain error type.
§Parameters
f: Consumes the domain source, if present; may perform caller-defined side effects. Framework failures do not invoke it.
§Returns
The mapped error retaining phase and input context, or the original framework failure unchanged.
Trait Implementations§
Source§impl<E: Clone> Clone for TranscodeDecodeError<E>
impl<E: Clone> Clone for TranscodeDecodeError<E>
Source§impl<E: Debug> Debug for TranscodeDecodeError<E>
impl<E: Debug> Debug for TranscodeDecodeError<E>
Source§impl<E> Display for TranscodeDecodeError<E>where
TranscodeDomainError<E>: Display,
impl<E> Display for TranscodeDecodeError<E>where
TranscodeDomainError<E>: Display,
impl<E: Eq> Eq for TranscodeDecodeError<E>
Source§impl<E> Error for TranscodeDecodeError<E>
impl<E> Error for TranscodeDecodeError<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()