pub enum ReadError<Decode, Read = Error> {
Read(Read),
Decode(Decode),
}Expand description
Returned when either reading or decoding fails.
Note that the Read type param only defaults to std::io::Error with std feature enabled.
Variants§
Implementations§
Source§impl<D, R> ReadError<D, R>
impl<D, R> ReadError<D, R>
Sourcepub fn convert_either<E>(self) -> E
pub fn convert_either<E>(self) -> E
Converts the inner errors to another type E.
Sourcepub fn map_read<E, F>(self, map: F) -> ReadError<D, E>where
F: FnOnce(R) -> E,
pub fn map_read<E, F>(self, map: F) -> ReadError<D, E>where
F: FnOnce(R) -> E,
Converts the read error using a closure.
This is analogous to Result::map/Result::map_err and leaves Decode intact.
Sourcepub fn map_decode<E, F>(self, map: F) -> ReadError<E, R>where
F: FnOnce(D) -> E,
pub fn map_decode<E, F>(self, map: F) -> ReadError<E, R>where
F: FnOnce(D) -> E,
Converts the decode error using a closure.
This is analogous to Result::map/Result::map_err and leaves Read intact.
Source§impl<E> ReadError<E, Infallible>
impl<E> ReadError<E, Infallible>
Sourcepub fn into_decode(self) -> E
pub fn into_decode(self) -> E
Statically proves that reading is infallible and converts to decode error.
Trait Implementations§
Source§impl<D: Error + 'static, R: Error + 'static> Error for ReadError<D, R>
Available on crate feature std only.
impl<D: Error + 'static, R: Error + 'static> Error for ReadError<D, R>
Available on crate feature
std only.Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl<E: Error + Send + Sync + 'static> From<ReadError<E>> for Error
Available on crate feature std only.
impl<E: Error + Send + Sync + 'static> From<ReadError<E>> for Error
Available on crate feature
std only.Source§impl From<ReadError<Infallible, Infallible>> for Infallible
impl From<ReadError<Infallible, Infallible>> for Infallible
Source§fn from(error: ReadError<Infallible, Infallible>) -> Self
fn from(error: ReadError<Infallible, Infallible>) -> Self
Converts to this type from the input type.
impl<Decode: Copy, Read: Copy> Copy for ReadError<Decode, Read>
impl<Decode: Eq, Read: Eq> Eq for ReadError<Decode, Read>
impl<Decode, Read> StructuralPartialEq for ReadError<Decode, Read>
Auto Trait Implementations§
impl<Decode, Read> Freeze for ReadError<Decode, Read>
impl<Decode, Read> RefUnwindSafe for ReadError<Decode, Read>where
Read: RefUnwindSafe,
Decode: RefUnwindSafe,
impl<Decode, Read> Send for ReadError<Decode, Read>
impl<Decode, Read> Sync for ReadError<Decode, Read>
impl<Decode, Read> Unpin for ReadError<Decode, Read>
impl<Decode, Read> UnwindSafe for ReadError<Decode, Read>where
Read: UnwindSafe,
Decode: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more