#[non_exhaustive]pub enum Error {
Show 16 variants
Custom(String),
Io(Error),
InvalidKey,
UnsupportedDataType(SpecialType),
WrongType {
expected: &'static str,
found: &'static str,
},
MismatchedKeyType {
expected: ObjectKind,
found: ObjectKind,
},
MismatchedElementType {
expected: ArrayKind,
found: ArrayKind,
},
TooLong,
InvalidHeader(u8),
Utf8(Utf8Error),
FromUtf8(FromUtf8Error),
Reserved,
InvalidTag,
NoChar,
InvalidComplexHeader,
InvalidMatrixType,
}Expand description
Errors that can occur during serialization or deserialization.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Custom(String)
A custom error message.
This variant is never directly constructed by this library, but rather is used for serde’s
Error traits1.
Io(Error)
InvalidKey
Returned when attempting to serialize an object key that is not a string or integer.
UnsupportedDataType(SpecialType)
Returned when trying to deserialize an unsupported data type.
This can occur when trying to deserialize an f16 or a bf16
without the half feature enabled. It can also occur when trying to deserialize a 128-bit
float, as these are not yet stable in Rust.
WrongType
Returned when a type is found during deserialization that doesn’t match the expected type
(e.g. deserialize_u8 is called but a u16 header
is encountered).
MismatchedKeyType
Returned when, during the serialization or deserialization of an object, a key is encountered that doesn’t match the first encountered key. Returned when, during the serialization or deserialization of an object, a key is
Objects in BEVE can be keyed by strings or integers, but all fields must be of the same type.
MismatchedElementType
TooLong
Returned either when trying to serialize data whose size is greater than (2^62)-1 bits or when trying to deserialize a size that is larger than the platform’s pointer width (e.g. trying to deserialize a 62-bit size on a 32-bit platform).
InvalidHeader(u8)
Returned when a header is encountered that does not fit the BEVE format.
Utf8(Utf8Error)
Returned when the deserialization of a str fails.
FromUtf8(FromUtf8Error)
Returned when the deserialization of a String fails.
Reserved
Returned when attempting to deserialize a reserved header.
InvalidTag
Returned when attempting to deserialize an enum tag as something other than an identifier.
NoChar
Returned when an empty string is attempted to be deserialized as a character.
InvalidComplexHeader
Returned when an invalid complex header is encountered.
InvalidMatrixType
Returned when attempting to deserialize part of a matrix as an improper type.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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 Error
impl Error for Error
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.