Enum bincode::error::DecodeError
source · [−]#[non_exhaustive]
pub enum DecodeError {
Show 16 variants
UnexpectedEnd,
LimitExceeded,
InvalidIntegerType {
expected: IntegerType,
found: IntegerType,
},
NonZeroTypeIsZero {
non_zero_type: IntegerType,
},
UnexpectedVariant {
type_name: &'static str,
allowed: AllowedEnumVariants,
found: u32,
},
Utf8(Utf8Error),
InvalidCharEncoding([u8; 4]),
InvalidBooleanValue(u8),
ArrayLengthMismatch {
required: usize,
found: usize,
},
OutsideUsizeRange(u64),
EmptyEnum {
type_name: &'static str,
},
InvalidDuration {
secs: u64,
nanos: u32,
},
InvalidSystemTime {
duration: Duration,
},
CStringNulError {
inner: NulError,
},
OtherString(String),
Serde(DecodeError),
}
Expand description
Errors that can be encountered by decoding a type
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
UnexpectedEnd
The reader reached its end but more bytes were expected.
LimitExceeded
The given configuration limit was exceeded
InvalidIntegerType
Fields
expected: IntegerType
The type that was being read from the reader
found: IntegerType
The type that was encoded in the data
Invalid type was found. The decoder tried to read type expected
, but found type found
instead.
NonZeroTypeIsZero
Fields
non_zero_type: IntegerType
The type that was being read from the reader
The decoder tried to decode any of the NonZero*
types but the value is zero
UnexpectedVariant
Fields
type_name: &'static str
The type name that was being decoded.
allowed: AllowedEnumVariants
The variants that are allowed
found: u32
The index of the enum that the decoder encountered
Invalid enum variant was found. The decoder tried to decode variant index found
, but the variant index should be between min
and max
.
Utf8(Utf8Error)
The decoder tried to decode a str
, but an utf8 error was encountered.
InvalidCharEncoding([u8; 4])
The decoder tried to decode a char
and failed. The given buffer contains the bytes that are read at the moment of failure.
InvalidBooleanValue(u8)
The decoder tried to decode a bool
and failed. The given value is what is actually read.
ArrayLengthMismatch
Fields
required: usize
The length of the array required by the rust type.
found: usize
The length of the array found in the binary format.
The decoder tried to decode an array of length required
, but the binary data contained an array of length found
.
OutsideUsizeRange(u64)
The encoded value is outside of the range of the target usize type.
This can happen if an usize was encoded on an architecture with a larger usize type and then decoded on an architecture with a smaller one. For example going from a 64 bit architecture to a 32 or 16 bit one may cause this error.
EmptyEnum
Fields
type_name: &'static str
The type that was being decoded
Tried to decode an enum with no variants
InvalidDuration
Fields
secs: u64
The number of seconds in the duration.
nanos: u32
The number of nanoseconds in the duration, which when converted to seconds and added to
secs
, overflows a u64
.
The decoder tried to decode a Duration and overflowed the number of seconds.
InvalidSystemTime
Fields
duration: Duration
The duration which could not have been added to
UNIX_EPOCH
The decoder tried to decode a SystemTime and overflowed
CStringNulError
Fields
inner: NulError
The inner exception
The decoder tried to decode a CString
, but the incoming data contained a 0 byte
OtherString(String)
An uncommon error occurred, see the inner text for more information
Serde(DecodeError)
A serde-specific error that occurred while decoding.
Trait Implementations
sourceimpl Debug for DecodeError
impl Debug for DecodeError
sourceimpl Display for DecodeError
impl Display for DecodeError
sourceimpl Error for DecodeError
impl Error for DecodeError
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl Error for DecodeError
This is supported on crate feature serde
only.
impl Error for DecodeError
serde
only.sourcefn custom<T>(msg: T) -> Self where
T: Display,
fn custom<T>(msg: T) -> Self where
T: Display,
Raised when there is general error when deserializing a type. Read more
sourcefn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a Deserialize
receives a type different from what it was
expecting. Read more
sourcefn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Raised when a Deserialize
receives a value of the right type but that
is wrong for some other reason. Read more
sourcefn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Raised when deserializing a sequence or map and the input data contains too many or too few elements. Read more
sourcefn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Raised when a Deserialize
enum type received a variant with an
unrecognized name. Read more
sourcefn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Raised when a Deserialize
struct type received a field with an
unrecognized name. Read more
sourcefn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Raised when a Deserialize
struct type expected to receive a required
field with a particular name but that field was not present in the
input. Read more
sourcefn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Raised when a Deserialize
struct type received more than one of the
same field. Read more
sourceimpl Into<DecodeError> for DecodeError
This is supported on crate feature serde
only.
impl Into<DecodeError> for DecodeError
serde
only.sourcefn into(self) -> DecodeError
fn into(self) -> DecodeError
Performs the conversion.
sourceimpl PartialEq<DecodeError> for DecodeError
impl PartialEq<DecodeError> for DecodeError
sourcefn eq(&self, other: &DecodeError) -> bool
fn eq(&self, other: &DecodeError) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &DecodeError) -> bool
fn ne(&self, other: &DecodeError) -> bool
This method tests for !=
.
impl StructuralPartialEq for DecodeError
Auto Trait Implementations
impl RefUnwindSafe for DecodeError
impl Send for DecodeError
impl Sync for DecodeError
impl Unpin for DecodeError
impl UnwindSafe for DecodeError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more