#[non_exhaustive]pub enum DecodeError {
Show 15 variants
UnexpectedEof {
needed: usize,
remaining: usize,
},
UnknownTag(u8),
InvalidBool(u8),
InvalidUtf8,
InvalidChar(u32),
LengthTooLarge {
count: u64,
remaining: usize,
},
DepthExceeded,
DuplicateKey,
DuplicateElement,
UnexpectedTag {
expected: &'static str,
got: u8,
},
UnknownVariant(String),
WriterOnlyVariant(u32),
BadVariantIndex(u32),
Malformed(&'static str),
TrailingBytes(usize),
}Expand description
Why decoding failed. A crafted message must never crash the decoder; every
malformed input becomes one of these (r[validate.*]).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnexpectedEof
Fewer bytes remain than the next read needs.
UnknownTag(u8)
A self-describing tag byte outside the defined table (r[validate.tags]).
InvalidBool(u8)
A bool byte other than 0 or 1.
InvalidUtf8
A string whose bytes are not valid UTF-8 (r[validate.text]).
InvalidChar(u32)
A char value that is not a Unicode scalar (r[validate.text]).
LengthTooLarge
A length or count larger than the remaining buffer could hold
(r[validate.lengths]).
DepthExceeded
Nesting deeper than the decoder’s bound (r[validate.depth]).
DuplicateKey
A duplicate key in a map (r[validate.uniqueness]).
DuplicateElement
A duplicate element in a set (r[validate.uniqueness]).
UnexpectedTag
A typed decode found a tag it did not expect for the type being read.
UnknownVariant(String)
A typed decode found an enum variant name it does not recognize.
WriterOnlyVariant(u32)
A compat decode received an enum variant the writer has but the reader
removed (r[compat.enum]); carries the wire variant index. The
DecodeError-channel counterpart of CompactError::WriterOnlyVariant.
BadVariantIndex(u32)
A compat decode received an enum variant index in neither the reader’s
variants nor the writer’s known set — hostile/garbage. Carries the wire
index. The DecodeError-channel counterpart of CompactError::BadVariantIndex.
Malformed(&'static str)
A typed decode found a structurally wrong value (e.g. an unexpected struct field count).
TrailingBytes(usize)
Bytes remained after a value that should have consumed the whole input.
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
Source§fn clone(&self) -> DecodeError
fn clone(&self) -> DecodeError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
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 DecodeError
impl PartialEq for DecodeError
Source§fn eq(&self, other: &DecodeError) -> bool
fn eq(&self, other: &DecodeError) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DecodeError
Auto Trait Implementations§
impl Freeze for DecodeError
impl RefUnwindSafe for DecodeError
impl Send for DecodeError
impl Sync for DecodeError
impl Unpin for DecodeError
impl UnsafeUnpin for DecodeError
impl UnwindSafe for DecodeError
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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.