Enum serde_assert::de::Error
source · 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 Token
s 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
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.