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() -> Error
pub fn input_exhausted() -> Error
Creates an Error which indicates that the input stream has ended prematurely.
Sourcepub fn length_mismatch(expected: usize, actual: usize) -> Error
pub fn length_mismatch(expected: usize, actual: usize) -> Error
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) -> Errorwhere
V: Display,
pub fn value_out_of_range<V>(value: V, type_name: &str) -> Errorwhere
V: Display,
Creates an Error which indicates that the input value is out of range.
Trait Implementations§
Source§impl Error for Error
Available on crate feature std only.
impl Error for Error
std only.1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.