Error

Trait Error 

Source
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§

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>(len: usize, expected: &T) -> Self
where T: ProductVisitor<'de>,

The product length was not as promised.

Source

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

There was a missing field at index.

Source

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

A field with index was specified more than once.

Source

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

A field with name field_name does not exist.

Source

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

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

Source

fn unknown_variant_name<'de, T>(name: &str, expected: &T) -> Self
where 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.

Implementors§