Enum bincode::error::DecodeError

source ·
#[non_exhaustive]
pub enum DecodeError {
Show 17 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),
}
Expand description

Errors that can be encountered by decoding a type

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.
§

UnexpectedEnd

The reader reached its end but more bytes were expected.

Fields

§additional: usize

Gives 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: IntegerType

The type that was being read from the reader

§found: IntegerType

The 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: IntegerType

The 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

§type_name: &'static str

The type name that was being decoded.

§allowed: &'static AllowedEnumVariants

The variants that are allowed

§found: u32

The index of the enum that the decoder encountered

§

Utf8

The decoder tried to decode a str, but an utf8 error was encountered.

Fields

§inner: Utf8Error

The inner error

§

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

§required: usize

The length of the array required by the rust type.

§found: usize

The length of the array found in the binary format.

§

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

Fields

§type_name: &'static str

The type that was being decoded

§

InvalidDuration

The decoder tried to decode a Duration and overflowed the number of seconds.

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.

§

InvalidSystemTime

The decoder tried to decode a SystemTime and overflowed

Fields

§duration: Duration

The 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

Fields

§position: usize

Nul byte position

§

Io

The reader encountered an IO error but more bytes were expected.

Fields

§inner: Error

The IO error expected

§additional: usize

Gives 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

Trait Implementations§

source§

impl Debug for DecodeError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for DecodeError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for DecodeError

source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.