pub trait Error: Sized {
// Required method
fn custom(msg: impl Display) -> Self;
// Provided methods
fn invalid_product_length<'de, T>(len: usize, expected: &T) -> Self
where T: ProductVisitor<'de> { ... }
fn missing_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Self
where T: ProductVisitor<'de> { ... }
fn duplicate_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Self
where T: ProductVisitor<'de> { ... }
fn unknown_field_name<'de, T>(field_name: &str, expected: &T) -> Self
where T: FieldNameVisitor<'de> { ... }
fn unknown_variant_tag<'de, T>(tag: u8, expected: &T) -> Self
where T: SumVisitor<'de> { ... }
fn unknown_variant_name<'de, T>(name: &str, expected: &T) -> Self
where T: VariantVisitor<'de> { ... }
}Expand description
The Error trait allows Deserialize implementations to create descriptive error messages
belonging to the Deserializer against which they are currently running.
Every Deserializer declares an Error type
that encompasses both general-purpose deserialization errors
as well as errors specific to the particular deserialization format.
Most deserializers should only need to provide the Error::custom method
and inherit the default behavior for the other methods.
Required Methods§
Provided Methods§
Sourcefn invalid_product_length<'de, T>(len: usize, expected: &T) -> Selfwhere
T: ProductVisitor<'de>,
fn invalid_product_length<'de, T>(len: usize, expected: &T) -> Selfwhere
T: ProductVisitor<'de>,
The product length was not as promised.
Sourcefn missing_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Selfwhere
T: ProductVisitor<'de>,
fn missing_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Selfwhere
T: ProductVisitor<'de>,
There was a missing field at index.
Sourcefn duplicate_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Selfwhere
T: ProductVisitor<'de>,
fn duplicate_field<'de, T>(
index: usize,
field_name: Option<&str>,
prod: &T,
) -> Selfwhere
T: ProductVisitor<'de>,
A field with index was specified more than once.
Sourcefn unknown_field_name<'de, T>(field_name: &str, expected: &T) -> Selfwhere
T: FieldNameVisitor<'de>,
fn unknown_field_name<'de, T>(field_name: &str, expected: &T) -> Selfwhere
T: FieldNameVisitor<'de>,
A field with name field_name does not exist.
Sourcefn unknown_variant_tag<'de, T>(tag: u8, expected: &T) -> Selfwhere
T: SumVisitor<'de>,
fn unknown_variant_tag<'de, T>(tag: u8, expected: &T) -> Selfwhere
T: SumVisitor<'de>,
The tag does not specify a variant of the sum type.
Sourcefn unknown_variant_name<'de, T>(name: &str, expected: &T) -> Selfwhere
T: VariantVisitor<'de>,
fn unknown_variant_name<'de, T>(name: &str, expected: &T) -> Selfwhere
T: VariantVisitor<'de>,
The name is not that of a variant of the sum type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.