#[non_exhaustive]pub enum ConstDecodeError {
Overflow,
InsufficientData(InsufficientData),
Other(&'static str),
}Expand description
Decoding varint error.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Overflow
The buffer does not contain a valid LEB128 encoding.
InsufficientData(InsufficientData)
The buffer does not contain enough data to decode.
Other(&'static str)
A custom error message.
Implementations§
Source§impl ConstDecodeError
impl ConstDecodeError
Sourcepub const fn overflow() -> ConstDecodeError
pub const fn overflow() -> ConstDecodeError
Creates a new ConstDecodeError::Overflow indicating that the decoded value would overflow the target type.
Sourcepub const fn insufficient_data(available: usize) -> ConstDecodeError
pub const fn insufficient_data(available: usize) -> ConstDecodeError
Creates a new ConstDecodeError::InsufficientData indicating that the buffer does not have enough data
to decode a value.
Sourcepub const fn insufficient_data_with_required(
required: NonZero<usize>,
available: usize,
) -> ConstDecodeError
pub const fn insufficient_data_with_required( required: NonZero<usize>, available: usize, ) -> ConstDecodeError
Creates a new ConstDecodeError::InsufficientData with the required and available bytes.
§Panics
Panics if required is not greater than available.
Sourcepub const fn other(msg: &'static str) -> ConstDecodeError
pub const fn other(msg: &'static str) -> ConstDecodeError
Creates a new ConstDecodeError::Other with the given message.
Sourcepub const fn into_decode_error(self) -> DecodeError
pub const fn into_decode_error(self) -> DecodeError
Converts this ConstDecodeError into a DecodeError.
§Example
use varing::{ConstDecodeError, DecodeError};
let const_error = ConstDecodeError::other("Other error message");
let error: DecodeError = const_error.into_decode_error();
let const_error_overflow = ConstDecodeError::overflow();
let error_overflow: DecodeError = const_error_overflow.into_decode_error();
let const_error_insufficient = ConstDecodeError::insufficient_data(5);
let error_insufficient: DecodeError = const_error_insufficient.into_decode_error();Trait Implementations§
Source§impl Clone for ConstDecodeError
impl Clone for ConstDecodeError
Source§fn clone(&self) -> ConstDecodeError
fn clone(&self) -> ConstDecodeError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConstDecodeError
impl Debug for ConstDecodeError
Source§impl Display for ConstDecodeError
impl Display for ConstDecodeError
impl Eq for ConstDecodeError
Source§impl Error for ConstDecodeError
impl Error for ConstDecodeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ConstDecodeError> for DecodeError
impl From<ConstDecodeError> for DecodeError
Source§fn from(e: ConstDecodeError) -> DecodeError
fn from(e: ConstDecodeError) -> DecodeError
Converts to this type from the input type.
Source§impl From<ConstDecodeError> for Error
Available on crate feature std only.
impl From<ConstDecodeError> for Error
Available on crate feature
std only.Source§fn from(err: ConstDecodeError) -> Error
fn from(err: ConstDecodeError) -> Error
Converts to this type from the input type.
Source§impl From<ConstDecodeError> for DecodeError
impl From<ConstDecodeError> for DecodeError
Source§fn from(err: ConstDecodeError) -> DecodeError
fn from(err: ConstDecodeError) -> DecodeError
Converts to this type from the input type.
Source§impl From<InsufficientData> for ConstDecodeError
impl From<InsufficientData> for ConstDecodeError
Source§fn from(source: InsufficientData) -> ConstDecodeError
fn from(source: InsufficientData) -> ConstDecodeError
Converts to this type from the input type.
Source§impl Hash for ConstDecodeError
impl Hash for ConstDecodeError
Source§impl PartialEq for ConstDecodeError
impl PartialEq for ConstDecodeError
Source§fn eq(&self, other: &ConstDecodeError) -> bool
fn eq(&self, other: &ConstDecodeError) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ConstDecodeError
Auto Trait Implementations§
impl Freeze for ConstDecodeError
impl RefUnwindSafe for ConstDecodeError
impl Send for ConstDecodeError
impl Sync for ConstDecodeError
impl Unpin for ConstDecodeError
impl UnsafeUnpin for ConstDecodeError
impl UnwindSafe for ConstDecodeError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more