pub struct Leb128DecodeError { /* private fields */ }Expand description
Error reported while decoding a LEB128 integer from a byte buffer.
Implementations§
Source§impl Leb128DecodeError
impl Leb128DecodeError
Sourcepub const fn incomplete(
start_index: usize,
required: NonZeroUsize,
available: usize,
) -> Self
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 fromstart_indexbefore decoding can make progress.available: Bytes currently available fromstart_index.
§Returns
Returns an error carrying incomplete-input context.
§Panics
Panics when required <= available, or when the one-past-available
error boundary overflows usize.
Sourcepub const fn malformed(
start_index: usize,
error_index: usize,
consumed: NonZeroUsize,
) -> Self
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.
Sourcepub const fn noncanonical(start_index: usize, consumed: NonZeroUsize) -> Self
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.
Sourcepub const fn kind(self) -> Leb128DecodeErrorKind
pub const fn kind(self) -> Leb128DecodeErrorKind
Returns the decoding error kind.
Sourcepub const fn start_index(self) -> usize
pub const fn start_index(self) -> usize
Returns the absolute byte index where the attempted value starts.
Sourcepub const fn error_index(self) -> usize
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.
Sourcepub const fn consumed(self) -> Option<NonZeroUsize>
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.
Sourcepub const fn is_incomplete(self) -> bool
pub const fn is_incomplete(self) -> bool
Returns whether this error reports an incomplete input prefix.
Sourcepub const fn is_malformed(self) -> bool
pub const fn is_malformed(self) -> bool
Returns whether this error reports malformed input.
Sourcepub const fn is_noncanonical(self) -> bool
pub const fn is_noncanonical(self) -> bool
Returns whether this error reports a non-canonical representation.
Sourcepub const fn required(self) -> Option<NonZeroUsize>
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.
Sourcepub const fn additional(self) -> Option<NonZeroUsize>
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.
Trait Implementations§
Source§impl Clone for Leb128DecodeError
impl Clone for Leb128DecodeError
Source§fn clone(&self) -> Leb128DecodeError
fn clone(&self) -> Leb128DecodeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Leb128DecodeError
Source§impl Debug for Leb128DecodeError
impl Debug for Leb128DecodeError
Source§impl Display for Leb128DecodeError
impl Display for Leb128DecodeError
impl Eq for Leb128DecodeError
Source§impl Error for Leb128DecodeError
impl Error for Leb128DecodeError
1.30.0 · 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 PartialEq for Leb128DecodeError
impl PartialEq for Leb128DecodeError
Source§fn eq(&self, other: &Leb128DecodeError) -> bool
fn eq(&self, other: &Leb128DecodeError) -> bool
self and other values to be equal, and is used by ==.