pub enum TranscodeError<E> {
InvalidInputIndex {
index: usize,
len: usize,
},
InvalidOutputIndex {
index: usize,
len: usize,
},
InsufficientOutput {
output_index: usize,
required: usize,
available: usize,
},
OutputLengthOverflow,
Domain(E),
}Expand description
Error reported by a transcode operation.
The enum keeps caller-contract failures in the framework layer and stores
codec-, charset-, or policy-specific failures in TranscodeError::Domain.
§Type Parameters
E: Domain error reported by the concrete transcoder.
Variants§
InvalidInputIndex
The caller supplied an input index beyond the input slice length.
Fields
InvalidOutputIndex
The caller supplied an output index beyond the output slice length.
Fields
InsufficientOutput
The output slice cannot hold required one-shot reset or finish output.
Fields
OutputLengthOverflow
Output length arithmetic overflowed.
Domain(E)
Domain-specific codec, charset, or policy error.
Implementations§
Source§impl<E> TranscodeError<E>
impl<E> TranscodeError<E>
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
Sourcepub const fn domain_ref(&self) -> Option<&E>
pub const fn domain_ref(&self) -> Option<&E>
Borrows the wrapped domain error.
§Returns
Returns Some(error) for TranscodeError::Domain and None for
framework contract errors.
Sourcepub fn map_domain<F, T>(self, f: F) -> TranscodeError<T>where
F: FnOnce(E) -> T,
pub fn map_domain<F, T>(self, f: F) -> TranscodeError<T>where
F: FnOnce(E) -> T,
Sourcepub fn ensure_transcode_indices(
input_len: usize,
input_index: usize,
output_len: usize,
output_index: usize,
) -> Result<(), Self>
pub fn ensure_transcode_indices( input_len: usize, input_index: usize, output_len: usize, output_index: usize, ) -> Result<(), Self>
Validates input and output start indices for a transcode call.
§Parameters
input_len: Length of the input slice.input_index: Input index supplied by the caller.output_len: Length of the output slice.output_index: Output index supplied by the caller.
§Returns
Returns Ok(()) when both indices are within their slices.
§Errors
Returns an invalid-input-index or invalid-output-index error when either index is beyond its slice.
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 one-shot finalization output.
§Parameters
output_len: Length of the output slice.output_index: Output index supplied by the caller.required: Output units required to finish in one call.
§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_output_range(
output_len: usize,
output_index: usize,
range_len: usize,
required: usize,
) -> Result<(), Self>
pub fn ensure_output_range( output_len: usize, output_index: usize, range_len: usize, required: usize, ) -> Result<(), Self>
Validates an indexed output range and its minimum writable capacity.
§Parameters
output_len: Length of the output slice.output_index: Output index supplied by the caller.range_len: Length of the writable range starting atoutput_index.required: Minimum output units required inside the range.
§Returns
Returns Ok(()) when the range fits inside the slice and can hold
required units.
§Errors
Returns an invalid-output-index error when the range overflows or
extends beyond the slice, or an insufficient-output error when
range_len is smaller than required.
Trait Implementations§
Source§impl<E: Clone> Clone for TranscodeError<E>
impl<E: Clone> Clone for TranscodeError<E>
Source§fn clone(&self) -> TranscodeError<E>
fn clone(&self) -> TranscodeError<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 TranscodeError<E>
Source§impl<E: Debug> Debug for TranscodeError<E>
impl<E: Debug> Debug for TranscodeError<E>
Source§impl<E> Display for TranscodeError<E>where
E: Display,
impl<E> Display for TranscodeError<E>where
E: Display,
impl<E: Eq> Eq for TranscodeError<E>
Source§impl<E> Error for TranscodeError<E>where
E: Error + 'static,
impl<E> Error for TranscodeError<E>where
E: Error + 'static,
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the source domain error, if any.
§Returns
Returns Some(error) for TranscodeError::Domain and None for
framework contract errors.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<E> From<E> for TranscodeError<E>
impl<E> From<E> for TranscodeError<E>
Source§impl<E: Hash> Hash for TranscodeError<E>
impl<E: Hash> Hash for TranscodeError<E>
Source§impl<E: PartialEq> PartialEq for TranscodeError<E>
impl<E: PartialEq> PartialEq for TranscodeError<E>
Source§fn eq(&self, other: &TranscodeError<E>) -> bool
fn eq(&self, other: &TranscodeError<E>) -> bool
self and other values to be equal, and is used by ==.