Skip to main content

FinishError

Enum FinishError 

Source
pub enum FinishError<E> {
    Capacity {
        source: CapacityError,
    },
    InvalidOutputIndex {
        index: usize,
        len: usize,
    },
    InsufficientOutput {
        output_index: usize,
        required: usize,
        available: usize,
    },
    Source {
        source: E,
    },
}
Expand description

Error reported by one-shot buffered finalization.

finish methods require enough output capacity to write all final output in one call. This type separates caller capacity mistakes from semantic errors reported by the concrete codec or hook policy.

Variants§

§

Capacity

Finish-output bound arithmetic overflowed.

Fields

§source: CapacityError

Capacity planning error.

§

InvalidOutputIndex

The caller supplied an output index outside the output slice.

Fields

§index: usize

Invalid output index supplied by the caller.

§len: usize

Length of the output slice.

§

InsufficientOutput

The output slice cannot hold all final output.

Fields

§output_index: usize

Absolute output index where finalization would start writing.

§required: usize

Output units required to finish in one call.

§available: usize

Output units available from output_index.

§

Source

The underlying codec or hook policy rejected finalization.

Fields

§source: E

Error returned by the concrete codec or hook policy.

Implementations§

Source§

impl<E> FinishError<E>

Source

pub const fn capacity(source: CapacityError) -> Self

Creates a finish error from capacity planning failure.

§Parameters
  • source: Capacity planning error reported while computing the finish bound.
§Returns

Returns a finish error wrapping source.

Source

pub const fn invalid_output_index(index: usize, len: usize) -> Self

Creates an invalid-output-index finish error.

§Parameters
  • index: Output index supplied by the caller.
  • len: Length of the output slice.
§Returns

Returns an invalid-output-index finish error.

Source

pub const fn insufficient_output( output_index: usize, required: usize, available: usize, ) -> Self

Creates an insufficient-output finish error.

§Parameters
  • output_index: Output index supplied by the caller.
  • required: Output units required to finish in one call.
  • available: Output units available from output_index.
§Returns

Returns an insufficient-output finish error.

Source

pub const fn source(source: E) -> Self

Creates a finish error from an underlying semantic error.

§Parameters
  • source: Error returned by the concrete codec or hook policy.
§Returns

Returns a finish error wrapping source.

Source

pub fn map_source<T, F>(self, map: F) -> FinishError<T>
where F: FnOnce(E) -> T,

Maps the underlying semantic error while preserving capacity failures.

§Type Parameters
  • T: Target semantic error type.
  • F: Mapping function type.
§Parameters
  • map: Function used to map the underlying semantic error.
§Returns

Returns a finish error with the mapped semantic error type.

Source

pub fn ensure_output_capacity( output_len: usize, output_index: usize, required: usize, ) -> Result<(), Self>

Validates that an output slice can hold one-shot final 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 FinishError::InvalidOutputIndex when output_index is beyond the slice, or FinishError::InsufficientOutput when fewer than required units are writable from output_index.

Trait Implementations§

Source§

impl<E: Clone> Clone for FinishError<E>

Source§

fn clone(&self) -> FinishError<E>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: Copy> Copy for FinishError<E>

Source§

impl<E: Debug> Debug for FinishError<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E> Display for FinishError<E>
where E: Display,

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Eq> Eq for FinishError<E>

Source§

impl<E> Error for FinishError<E>
where E: Error + 'static, Self: Debug + Display,

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<E: Hash> Hash for FinishError<E>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E: PartialEq> PartialEq for FinishError<E>

Source§

fn eq(&self, other: &FinishError<E>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E> StructuralPartialEq for FinishError<E>

Auto Trait Implementations§

§

impl<E> Freeze for FinishError<E>
where E: Freeze,

§

impl<E> RefUnwindSafe for FinishError<E>
where E: RefUnwindSafe,

§

impl<E> Send for FinishError<E>
where E: Send,

§

impl<E> Sync for FinishError<E>
where E: Sync,

§

impl<E> Unpin for FinishError<E>
where E: Unpin,

§

impl<E> UnsafeUnpin for FinishError<E>
where E: UnsafeUnpin,

§

impl<E> UnwindSafe for FinishError<E>
where E: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.