Skip to main content

Leb128DecodeError

Struct Leb128DecodeError 

Source
pub struct Leb128DecodeError { /* private fields */ }
Expand description

Error reported while decoding a LEB128 integer from a byte buffer.

Implementations§

Source§

impl Leb128DecodeError

Source

pub const fn incomplete( start_index: usize, required: NonZeroUsize, available: usize, ) -> Self

Creates an incomplete-input decoding error.

§Parameters
  • start_index: Byte index where the incomplete value starts.
  • required: Non-zero lower bound for total bytes that must be readable from start_index before decoding can make progress.
  • available: Bytes currently available from start_index.
§Returns

Returns an error carrying incomplete-input context.

§Panics

Panics when required <= available, or when the one-past-available error boundary overflows usize.

Source

pub const fn malformed( start_index: usize, error_index: usize, consumed: NonZeroUsize, ) -> Self

Creates a malformed-input decoding error.

§Parameters
  • start_index: Byte index where the malformed value starts.
  • error_index: Byte index at which the malformed input was detected.
  • consumed: Non-zero bytes the caller may consume to make progress.
§Returns

Returns an error carrying malformed-input context.

§Panics

Panics when error_index is outside the consumed span.

Source

pub const fn noncanonical(start_index: usize, consumed: NonZeroUsize) -> Self

Creates a non-canonical-input decoding error.

§Parameters
  • start_index: Byte index where the non-canonical value starts.
  • consumed: Non-zero bytes the caller may consume to make progress.
§Returns

Returns an error carrying non-canonical-input context.

§Panics

Panics when the last consumed byte index overflows usize.

Source

pub const fn kind(self) -> Leb128DecodeErrorKind

Returns the decoding error kind.

Source

pub const fn start_index(self) -> usize

Returns the absolute byte index where the attempted value starts.

Source

pub const fn error_index(self) -> usize

Returns the absolute byte index where the error was detected.

§Returns

Returns the byte index that made the error observable. For incomplete input this is the one-past-available boundary where the next byte would be required, so it may be equal to the input length visible to the caller.

Source

pub const fn consumed(self) -> Option<NonZeroUsize>

Returns bytes that may be consumed after an invalid-input error.

§Returns

Returns Some(consumed) for invalid input, or None for incomplete input.

Source

pub const fn is_incomplete(self) -> bool

Returns whether this error reports an incomplete input prefix.

Source

pub const fn is_malformed(self) -> bool

Returns whether this error reports malformed input.

Source

pub const fn is_noncanonical(self) -> bool

Returns whether this error reports a non-canonical representation.

Source

pub const fn required(self) -> Option<NonZeroUsize>

Returns a lower bound for bytes required to continue incomplete decoding.

§Returns

Returns Some(required) for incomplete input, or None otherwise. The returned value is a non-zero lower bound for the total readable bytes required from Self::start_index before decoding can make progress; it does not guarantee that the value will be complete at exactly that length.

Source

pub const fn additional(self) -> Option<NonZeroUsize>

Returns additional bytes required to continue incomplete decoding.

§Returns

Returns Some(additional) for incomplete input, or None otherwise. The value is required - available and is guaranteed to be non-zero.

Source

pub const fn available(self) -> Option<usize>

Returns bytes available for an incomplete value.

§Returns

Returns Some(available) for incomplete input, or None otherwise.

Trait Implementations§

Source§

impl Clone for Leb128DecodeError

Source§

fn clone(&self) -> Leb128DecodeError

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 Copy for Leb128DecodeError

Source§

impl Debug for Leb128DecodeError

Source§

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

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

impl Display for Leb128DecodeError

Source§

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

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

impl Eq for Leb128DecodeError

Source§

impl Error for Leb128DecodeError

1.30.0 · 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 PartialEq for Leb128DecodeError

Source§

fn eq(&self, other: &Leb128DecodeError) -> 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 StructuralPartialEq for Leb128DecodeError

Auto Trait Implementations§

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.