pub enum TranscodeEncodeError<E, V> {
Failure(TranscodeFailure),
Unencodable {
input_index: usize,
value: Option<V>,
},
Domain(TranscodeDomainError<E>),
}Expand description
Error reported by an encode-oriented transcode operation.
§Type Parameters
E: Domain error preserved from the codec or policy.V: Optional owned context for an unencodable input value.
§Examples
use qubit_codec::TranscodeEncodeError;
let error = TranscodeEncodeError::<(), u8>::unencodable(3, 255);
assert_eq!(error.unencodable_ref(), Some((3, Some(&255))));Variants§
Failure(TranscodeFailure)
Framework-level transcode failure.
Tuple Fields
0: TranscodeFailureFramework contract failure preserved as the error source.
Unencodable
The input value cannot be encoded by the target codec and policy.
Fields
Domain(TranscodeDomainError<E>)
Domain-specific codec, charset, or policy error.
Tuple Fields
0: TranscodeDomainError<E>Owned domain source and its reset, main, or finish context.
Implementations§
Source§impl<E, V> TranscodeEncodeError<E, V>
impl<E, V> TranscodeEncodeError<E, V>
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_finish(source: E) -> Self
pub const fn domain_finish(source: E) -> Self
Sourcepub fn unencodable(input_index: usize, value: V) -> Self
pub fn unencodable(input_index: usize, value: V) -> Self
Sourcepub const fn unencodable_without_context(input_index: usize) -> Self
pub const fn unencodable_without_context(input_index: usize) -> Self
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
Returns Some borrowed framework failure for Failure, otherwise None.
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
Returns Some borrowed domain error and phase context for Domain,
or None for framework and unencodable errors.
Sourcepub const fn domain_ref(&self) -> Option<&E>
pub const fn domain_ref(&self) -> Option<&E>
Borrows the wrapped domain error.
§Returns
Returns Some borrowed domain source for Domain, otherwise None.
Sourcepub const fn unencodable_ref(&self) -> Option<(usize, Option<&V>)>
pub const fn unencodable_ref(&self) -> Option<(usize, Option<&V>)>
Borrows the unencodable value context carried by this error.
§Returns
Returns Some((index, value)) for Unencodable, otherwise None.
The nested option is Some when a retained value can be borrowed,
and None when the error has only an input index.
Sourcepub fn map_domain<F, T>(self, f: F) -> TranscodeEncodeError<T, V>where
F: FnOnce(E) -> T,
pub fn map_domain<F, T>(self, f: F) -> TranscodeEncodeError<T, V>where
F: FnOnce(E) -> T,
Maps the wrapped domain error while preserving other errors.
§Type Parameters
F: Callback consuming the domain source.T: Replacement domain error type.
§Parameters
f: Called exactly once for Domain, never for other variants.
§Returns
Returns an error with the transformed domain source while preserving phase, input position, framework failures, and unencodable value context.
Sourcepub fn map_value<F, W>(self, f: F) -> TranscodeEncodeError<E, W>where
F: FnOnce(V) -> W,
pub fn map_value<F, W>(self, f: F) -> TranscodeEncodeError<E, W>where
F: FnOnce(V) -> W,
Maps value context carried by unencodable-value errors.
§Type Parameters
F: Callback consuming a retained value.W: Replacement value-context type.
§Parameters
f: Called once for a retained unencodable value, otherwise not called.
§Returns
Returns an error with transformed value context; absent context and other variants are preserved.
Trait Implementations§
Source§impl<E, V> Display for TranscodeEncodeError<E, V>where
TranscodeDomainError<E>: Display,
impl<E, V> Display for TranscodeEncodeError<E, V>where
TranscodeDomainError<E>: Display,
impl<E: Eq, V: Eq> Eq for TranscodeEncodeError<E, V>
Source§impl<E, V> Error for TranscodeEncodeError<E, V>
impl<E, V> Error for TranscodeEncodeError<E, V>
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()