#[non_exhaustive]pub enum TranscodeFailure {
Show 15 variants
InvalidInputIndex {
index: usize,
input_len: usize,
},
InvalidOutputIndex {
index: usize,
output_len: usize,
},
InvalidOutputRange {
output_index: usize,
range_len: usize,
output_len: usize,
},
InsufficientOutput {
output_index: usize,
required: usize,
available: usize,
},
OutputLengthOverflow,
AllocationFailed,
IncompleteInput {
input_index: usize,
required: usize,
available: usize,
},
InvalidProgress {
source: TranscodeContractError,
},
TrailingInput {
consumed: usize,
remaining: usize,
},
UnsupportedDecodeLifecycleOutput {
reset_bound: usize,
finish_bound: usize,
},
TranscodeAfterFinish,
TranscodeBeforeReset,
FinishAfterFinish,
FinishBeforeReset,
LifecyclePoisoned,
}Expand description
Framework-level failure reported by a transcode operation.
These failures are part of the safe public transcode API. They describe caller-supplied buffer ranges, capacity planning, complete-input shape, and stream lifecycle misuse that the transcode layer can detect without interpreting a concrete codec error.
§Examples
use qubit_codec::TranscodeFailure;
let failure = TranscodeFailure::invalid_input_index(4, 3);
assert_eq!(failure.to_string(), "invalid input index 4 for input length 3");
assert_eq!(TranscodeFailure::ensure_input_index(3, 4), Err(failure));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidInputIndex
The caller supplied an input index outside the input slice.
Fields
InvalidOutputIndex
The caller supplied an output index outside the output slice.
Fields
InvalidOutputRange
The caller supplied an output range extending beyond the output slice.
Fields
InsufficientOutput
The output slice cannot hold all required output.
Fields
OutputLengthOverflow
Output length arithmetic overflowed.
AllocationFailed
The allocator could not reserve the requested output storage.
IncompleteInput
The complete input ended with an incomplete value.
Fields
InvalidProgress
A transcoder returned progress inconsistent with the supplied buffers.
Fields
source: TranscodeContractErrorContract error describing the invalid progress.
TrailingInput
The input contains exactly one decoded value plus trailing units.
Fields
UnsupportedDecodeLifecycleOutput
A strict single-value decoder cannot expose codec lifecycle output.
Fields
TranscodeAfterFinish
transcode was called after the logical stream was finished.
TranscodeBeforeReset
transcode was called before the first successful reset.
FinishAfterFinish
finish was called after the logical stream was already finished.
FinishBeforeReset
finish was called before the first successful reset.
LifecyclePoisoned
Reset or finish failed after codec, hook, or buffered state may have changed. Continuing could repeat side effects or observe inconsistent state; a successful reset is required before further use.
Implementations§
Source§impl TranscodeFailure
impl TranscodeFailure
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 invalid_output_range(
output_index: usize,
range_len: usize,
output_len: usize,
) -> Self
pub const fn invalid_output_range( output_index: usize, range_len: usize, output_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 output_length_overflow() -> Self
pub const fn output_length_overflow() -> Self
Creates an output-length-overflow error.
§Returns
Returns the framework marker for unrepresentable output capacity.
Sourcepub const fn allocation_failed() -> Self
pub const fn allocation_failed() -> Self
Creates an output-allocation failure.
§Returns
Returns the framework marker for a failed output allocation.
Sourcepub const fn incomplete_input(
input_index: usize,
required: usize,
available: usize,
) -> Self
pub const fn incomplete_input( input_index: usize, required: usize, available: usize, ) -> Self
Creates an incomplete-input error.
§Parameters
input_index: Absolute index where the incomplete value starts.required: Current minimum total units needed from that index.available: Units currently available from that index.
§Returns
Returns a failure preserving the incomplete tail and retry requirement.
Sourcepub const fn invalid_progress(source: TranscodeContractError) -> Self
pub const fn invalid_progress(source: TranscodeContractError) -> Self
Sourcepub const fn trailing_input(consumed: usize, remaining: usize) -> Self
pub const fn trailing_input(consumed: usize, remaining: usize) -> Self
Sourcepub const fn unsupported_decode_lifecycle_output(
reset_bound: usize,
finish_bound: usize,
) -> Self
pub const fn unsupported_decode_lifecycle_output( reset_bound: usize, finish_bound: usize, ) -> Self
Sourcepub fn ensure_input_index(
input_len: usize,
input_index: usize,
) -> Result<(), Self>
pub fn ensure_input_index( input_len: usize, input_index: usize, ) -> Result<(), Self>
Validates that input_index is within an input slice.
§Parameters
input_len: Total input slice length.input_index: Absolute start index, including the end boundary.
§Returns
Returns Ok(()) when the index is at most the input length.
§Errors
Returns Self::InvalidInputIndex when the index exceeds the length.
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: Total input slice length.input_index: Absolute start of the input region.min_required: Minimum readable units required from that start.
§Returns
Returns Ok(()) when the start index and minimum readable capacity are
valid.
§Errors
Returns Self::InvalidInputIndex for an invalid start, or
Self::IncompleteInput when fewer than min_required units remain.
Sourcepub fn ensure_no_trailing_input(
consumed: usize,
input_len: usize,
) -> Result<(), Self>
pub fn ensure_no_trailing_input( consumed: usize, input_len: usize, ) -> Result<(), Self>
Validates a consumed input count and rejects trailing input.
§Parameters
consumed: Number of input units consumed by the decoded value.input_len: Total number of input units supplied.
§Returns
Returns Ok(()) when consumed == input_len.
§Errors
Returns TranscodeFailure::InvalidInputIndex when consumed exceeds
input_len, or TranscodeFailure::TrailingInput when unconsumed
input remains.
Sourcepub fn ensure_output_index(
output_len: usize,
output_index: usize,
) -> Result<(), Self>
pub fn ensure_output_index( output_len: usize, output_index: usize, ) -> Result<(), Self>
Validates that output_index is within an output slice.
§Parameters
output_len: Total output slice length.output_index: Absolute start index, including the end boundary.
§Returns
Returns Ok(()) when the index is at most the output length.
§Errors
Returns Self::InvalidOutputIndex when the index exceeds the length.
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: Total input slice length.input_index: Absolute starting input index.output_len: Total output slice length.output_index: Absolute starting output index.
§Returns
Returns Ok(()) when both indices lie within their slices or at their
ends.
§Errors
Returns Self::InvalidInputIndex first for invalid input, otherwise
Self::InvalidOutputIndex for invalid output.
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: Total output slice length.output_index: Absolute start of the writable region.required: Minimum output units needed from that start.
§Returns
Returns Ok(()) when the output region has at least required units.
§Errors
Returns Self::InvalidOutputIndex for an invalid start, or
Self::InsufficientOutput when the remaining capacity is too small.
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: Total output slice length.output_index: Absolute start of the writable range.range_len: Length of the caller-selected writable range.required: Minimum capacity required within the selected range.
§Returns
Returns Ok(()) when the selected range fits and has enough capacity.
§Errors
Returns Self::InvalidOutputIndex for an invalid start,
Self::InvalidOutputRange when the range exceeds the slice, or
Self::InsufficientOutput when the selected range is too short.
Trait Implementations§
Source§impl Clone for TranscodeFailure
impl Clone for TranscodeFailure
impl Copy for TranscodeFailure
Source§impl Debug for TranscodeFailure
impl Debug for TranscodeFailure
Source§impl Display for TranscodeFailure
impl Display for TranscodeFailure
impl Eq for TranscodeFailure
Source§impl Error for TranscodeFailure
impl Error for TranscodeFailure
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 From<CapacityError> for TranscodeFailure
impl From<CapacityError> for TranscodeFailure
Source§impl From<TranscodeContractError> for TranscodeFailure
impl From<TranscodeContractError> for TranscodeFailure
Source§fn from(error: TranscodeContractError) -> Self
fn from(error: TranscodeContractError) -> Self
Converts a broken transcoder progress report into a framework failure.
§Parameters
error: Progress-contract violation to retain as the error source.
§Returns
Returns Self::InvalidProgress carrying the original violation.