#[non_exhaustive]pub enum DecodeError {
Show 18 variants
UnexpectedEnd {
additional: usize,
},
LimitExceeded,
InvalidIntegerType {
expected: IntegerType,
found: IntegerType,
},
NonZeroTypeIsZero {
non_zero_type: IntegerType,
},
UnexpectedVariant {
type_name: &'static str,
allowed: &'static AllowedEnumVariants,
found: u32,
},
Utf8 {
inner: 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 {
position: usize,
},
Io {
inner: Error,
additional: usize,
},
Other(&'static str),
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.
Fields
additional: usizeGives an estimate of how many extra bytes are needed.
Note: this is only an estimate and not indicative of the actual bytes needed.
Note: Bincode has no look-ahead mechanism. This means that this will only return the amount of bytes to be read for the current action, and not take into account the entire data structure being read.
LimitExceeded
The given configuration limit was exceeded
InvalidIntegerType
Invalid type was found. The decoder tried to read type expected, but found type found instead.
Fields
expected: IntegerTypeThe type that was being read from the reader
found: IntegerTypeThe type that was encoded in the data
NonZeroTypeIsZero
The decoder tried to decode any of the NonZero* types but the value is zero
Fields
non_zero_type: IntegerTypeThe type that was being read from the reader
UnexpectedVariant
Invalid enum variant was found. The decoder tried to decode variant index found, but the variant index should be between min and max.
Fields
allowed: &'static AllowedEnumVariantsThe variants that are allowed
Utf8
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
The decoder tried to decode an array of length required, but the binary data contained an array of length found.
Fields
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
Tried to decode an enum with no variants
InvalidDuration
The decoder tried to decode a Duration and overflowed the number of seconds.
Fields
InvalidSystemTime
The decoder tried to decode a SystemTime and overflowed
Fields
duration: DurationThe duration which could not have been added to
UNIX_EPOCH
CStringNulError
The decoder tried to decode a CString, but the incoming data contained a 0 byte
Io
The reader encountered an IO error but more bytes were expected.
Fields
additional: usizeGives an estimate of how many extra bytes are needed.
Note: this is only an estimate and not indicative of the actual bytes needed.
Note: Bincode has no look-ahead mechanism. This means that this will only return the amount of bytes to be read for the current action, and not take into account the entire data structure being read.
Other(&'static str)
An uncommon error occurred, see the inner text for more information
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§
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
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
Source§impl Error for DecodeError
impl Error for DecodeError
Source§fn custom<T>(msg: T) -> Selfwhere
T: Display,
fn custom<T>(msg: T) -> Selfwhere
T: Display,
Source§fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_type(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a type different from what it was
expecting. Read moreSource§fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
fn invalid_value(unexp: Unexpected<'_>, exp: &dyn Expected) -> Self
Deserialize receives a value of the right type but that
is wrong for some other reason. Read moreSource§fn invalid_length(len: usize, exp: &dyn Expected) -> Self
fn invalid_length(len: usize, exp: &dyn Expected) -> Self
Source§fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self
Deserialize enum type received a variant with an
unrecognized name.Source§fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self
Deserialize struct type received a field with an
unrecognized name.Source§fn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Deserialize struct type expected to receive a required
field with a particular name but that field was not present in the
input.Source§fn duplicate_field(field: &'static str) -> Self
fn duplicate_field(field: &'static str) -> Self
Deserialize struct type received more than one of the
same field.