pub trait Error: Sized {
// Required methods
fn syntax(msg: &str) -> Self;
fn end_of_stream() -> Self;
fn unknown_field(field: &str) -> Self;
fn missing_field(field: &'static str) -> Self;
// Provided methods
fn length_mismatch(_len: usize) -> Self { ... }
fn type_mismatch(_type: Type) -> Self { ... }
fn invalid_value(msg: &str) -> Self { ... }
}
Expand description
Error
is a trait that allows a Deserialize
to generically create a
Deserializer
error.
Required Methods§
Sourcefn end_of_stream() -> Self
fn end_of_stream() -> Self
Raised when a Deserialize
type unexpectedly hit the end of the stream.
Sourcefn unknown_field(field: &str) -> Self
fn unknown_field(field: &str) -> Self
Raised when a Deserialize
struct type received an unexpected struct field.
Sourcefn missing_field(field: &'static str) -> Self
fn missing_field(field: &'static str) -> Self
Raised when a Deserialize
struct type did not receive a field.
Provided Methods§
Sourcefn length_mismatch(_len: usize) -> Self
fn length_mismatch(_len: usize) -> Self
Raised when a fixed sized sequence or map was passed in the wrong amount of arguments.
Sourcefn type_mismatch(_type: Type) -> Self
fn type_mismatch(_type: Type) -> Self
Raised when a Deserialize
was passed an incorrect type.
Sourcefn invalid_value(msg: &str) -> Self
fn invalid_value(msg: &str) -> Self
Raised when a Deserialize
was passed an incorrect value.
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.