pub trait Error: Sized {
    // Required method
    fn custom(msg: impl Display) -> Self;

    // Provided methods
    fn invalid_product_length<'de, T: ProductVisitor<'de>>(
        len: usize,
        expected: &T
    ) -> Self { ... }
    fn missing_field<'de, T: ProductVisitor<'de>>(
        index: usize,
        field_name: Option<&str>,
        prod: &T
    ) -> Self { ... }
    fn duplicate_field<'de, T: ProductVisitor<'de>>(
        index: usize,
        field_name: Option<&str>,
        prod: &T
    ) -> Self { ... }
    fn unknown_field_name<'de, T: FieldNameVisitor<'de>>(
        field_name: &str,
        expected: &T
    ) -> Self { ... }
    fn unknown_variant_tag<'de, T: SumVisitor<'de>>(
        tag: u8,
        expected: &T
    ) -> Self { ... }
    fn unknown_variant_name<T: VariantVisitor>(name: &str, expected: &T) -> Self { ... }
}
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§

source

fn custom(msg: impl Display) -> Self

Raised when there is general error when deserializing a type.

Provided Methods§

source

fn invalid_product_length<'de, T: ProductVisitor<'de>>( len: usize, expected: &T ) -> Self

The product length was not as promised.

source

fn missing_field<'de, T: ProductVisitor<'de>>( index: usize, field_name: Option<&str>, prod: &T ) -> Self

There was a missing field at index.

source

fn duplicate_field<'de, T: ProductVisitor<'de>>( index: usize, field_name: Option<&str>, prod: &T ) -> Self

A field with index was specified more than once.

source

fn unknown_field_name<'de, T: FieldNameVisitor<'de>>( field_name: &str, expected: &T ) -> Self

A field with name field_name does not exist.

source

fn unknown_variant_tag<'de, T: SumVisitor<'de>>(tag: u8, expected: &T) -> Self

The tag does not specify a variant of the sum type.

source

fn unknown_variant_name<T: VariantVisitor>(name: &str, expected: &T) -> Self

The name is not that of a variant of the sum type.

Object Safety§

This trait is not object safe.

Implementors§