pub struct Error { /* private fields */ }
Expand description
Error type for any encoding/decoding operations.
A simple string representation is forced onto all implementations for simplicity. This is because most of the time, a encoding/decoding error indicates a bug that requires human attention to fix anyway; even when handling untrusted data, the program is likely to only be interested in knowing that an error did occur, instead of handling based on cause.
There might be cases where allocations must be avoided. A feature could be added in the future
that turns the repr
into ()
to address this. Such a feature would be a non-breaking change
so there’s no need to add it now.
Implementations§
Source§impl Error
impl Error
Sourcepub fn input_exhausted() -> Self
pub fn input_exhausted() -> Self
Creates an Error
which indicates that the input stream has ended prematurely.
Sourcepub fn length_mismatch(expected: usize, actual: usize) -> Self
pub fn length_mismatch(expected: usize, actual: usize) -> Self
Creates an Error
which indicates that the length (likely prefix) is different from the
expected value.
Sourcepub fn value_out_of_range<V>(value: V, type_name: &str) -> Selfwhere
V: Display,
pub fn value_out_of_range<V>(value: V, type_name: &str) -> Selfwhere
V: Display,
Creates an Error
which indicates that the input value is out of range.
Sourcepub fn unknown_enum_tag<V>(tag: V, type_name: &str) -> Selfwhere
V: Display,
pub fn unknown_enum_tag<V>(tag: V, type_name: &str) -> Selfwhere
V: Display,
Creates an Error
which indicates that the enum tag does not belong to a known variant.