pub trait Error: Send + Sized + Error {
// Required method
fn custom<T: Display>(msg: T) -> Self;
// Provided methods
fn invalid_type<U: Display, E: Display>(unexp: U, exp: E) -> Self { ... }
fn invalid_value<U: Display, E: Display>(unexp: U, exp: E) -> Self { ... }
fn invalid_length<E: Display>(len: usize, exp: E) -> Self { ... }
}
Expand description
The Error
trait allows FromStream
implementations to create descriptive
error messages belonging to their Decoder
context.
Most implementors should only need to provide the Error::custom
method
and inherit the default behavior for the other methods.
Based on serde::de::Error
.
Required Methods§
Provided Methods§
sourcefn invalid_type<U: Display, E: Display>(unexp: U, exp: E) -> Self
fn invalid_type<U: Display, E: Display>(unexp: U, exp: E) -> Self
Raised when FromStream
receives a type different from what it was expecting.
sourcefn invalid_value<U: Display, E: Display>(unexp: U, exp: E) -> Self
fn invalid_value<U: Display, E: Display>(unexp: U, exp: E) -> Self
Raised when FromStream
receives a value of the right type but that
is wrong for some other reason.
sourcefn invalid_length<E: Display>(len: usize, exp: E) -> Self
fn invalid_length<E: Display>(len: usize, exp: E) -> Self
Raised when decoding a sequence or map and the input data contains too many or too few elements.
Object Safety§
This trait is not object safe.