pub enum ErrorKind {
Io(Error),
InvalidUtf8Encoding(Utf8Error),
InvalidBoolEncoding(u8),
InvalidCharEncoding,
InvalidTagEncoding(usize),
DeserializeAnyNotSupported,
SizeLimit,
SequenceMustHaveLength,
Custom(String),
}
Expand description
The kind of error that can be produced during a serialization or deserialization.
Variants§
Io(Error)
If the error stems from the reader/writer that is being used during (de)serialization, that error will be stored and returned here.
InvalidUtf8Encoding(Utf8Error)
Returned if the deserializer attempts to deserialize a string that is not valid utf8
InvalidBoolEncoding(u8)
Returned if the deserializer attempts to deserialize a bool that was not encoded as either a 1 or a 0
InvalidCharEncoding
Returned if the deserializer attempts to deserialize a char that is not in the correct format.
InvalidTagEncoding(usize)
Returned if the deserializer attempts to deserialize the tag of an enum that is not in the expected ranges
DeserializeAnyNotSupported
Serde has a deserialize_any method that lets the format hint to the object which route to take in deserializing.
SizeLimit
If (de)serializing a message takes more than the provided size limit, this error is returned.
SequenceMustHaveLength
Bincode can not encode sequences of unknown length (like iterators).
Custom(String)
A custom error message from Serde.
Trait Implementations§
source§impl Error for Box<ErrorKind>
impl Error for Box<ErrorKind>
source§fn custom<T>(desc: T) -> Box<ErrorKind>where
T: Display,
fn custom<T>(desc: T) -> Box<ErrorKind>where
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.