pub enum Error {
Show 18 variants
EndOfTokens,
ExpectedSeqEnd,
ExpectedTupleEnd,
ExpectedTupleStructEnd,
ExpectedTupleVariantEnd,
ExpectedMapEnd,
ExpectedStructEnd,
ExpectedStructVariantEnd,
UnsupportedEnumDeserializerMethod,
NotSelfDescribing,
Custom(String),
InvalidType(String, String),
InvalidValue(String, String),
InvalidLength(usize, String),
UnknownVariant(String, &'static [&'static str]),
UnknownField(String, &'static [&'static str]),
MissingField(&'static str),
DuplicateField(&'static str),
}Expand description
An error encountered during deserialization.
§Example
use serde::de::Error as _;
use serde_assert::de::Error;
assert_eq!(
format!("{}", Error::missing_field("foo")),
"missing field foo"
);Variants§
EndOfTokens
The Deserializer reached the end of the input Tokens before deserialization was
completed.
ExpectedSeqEnd
Expected a Token::SeqEnd.
ExpectedTupleEnd
Expected a Token::TupleEnd.
ExpectedTupleStructEnd
Expected a Token::TupleStructEnd.
ExpectedTupleVariantEnd
Expected a Token::TupleVariantEnd.
ExpectedMapEnd
Expected a Token::MapEnd.
ExpectedStructEnd
Expected a Token::StructEnd.
ExpectedStructVariantEnd
Expected a Token::StructVariantEnd.
UnsupportedEnumDeserializerMethod
An unsupported serde::Deserializer method was called during deserialization of an
enum variant.
If you encounter this error, check what methods you are calling when deserializing your
enum variants. Many standard serde types are not supported in this context.
NotSelfDescribing
The Deserializer was set to be non-self-describing, but the Deserialize
implementation made a call to deserialize_any().
Custom(String)
An error created by calling custom().
InvalidType(String, String)
An error created by calling invalid_type().
InvalidValue(String, String)
An error created by calling invalid_value().
InvalidLength(usize, String)
An error created by calling invalid_length().
UnknownVariant(String, &'static [&'static str])
An error created by calling unknown_variant().
UnknownField(String, &'static [&'static str])
An error created by calling unknown_field().
MissingField(&'static str)
An error created by calling missing_field().
DuplicateField(&'static str)
An error created by calling duplicate_field().
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · 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(unexpected: Unexpected<'_>, expected: &dyn Expected) -> Self
fn invalid_type(unexpected: Unexpected<'_>, expected: &dyn Expected) -> Self
Deserialize receives a type different from what it was
expecting. Read moreSource§fn invalid_value(unexpected: Unexpected<'_>, expected: &dyn Expected) -> Self
fn invalid_value(unexpected: Unexpected<'_>, expected: &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, expected: &dyn Expected) -> Self
fn invalid_length(len: usize, expected: &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.