Trait IntoError

Source
pub trait IntoError<T>: Sealed
where Self: Sized,
{ // Required method fn ok_or_error<C, F>(self, kind: ErrorKind, f: F) -> Result<T, Error> where C: ToString, F: FnOnce() -> C; // Provided methods fn ok_or_invalid_data<C, F>(self, f: F) -> Result<T, Error> where C: ToString, F: FnOnce() -> C { ... } fn ok_or_invalid_input<C, F>(self, f: F) -> Result<T, Error> where C: ToString, F: FnOnce() -> C { ... } fn ok_or_not_found<C, F>(self, f: F) -> Result<T, Error> where C: ToString, F: FnOnce() -> C { ... } fn ok_or_unexpected_eof<C, F>(self, f: F) -> Result<T, Error> where C: ToString, F: FnOnce() -> C { ... } }
Expand description

A trait providing conversion shortcuts for creating Error instances.

Required Methods§

Source

fn ok_or_error<C, F>(self, kind: ErrorKind, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Unwrap self into an Ok or an Error of the given kind.

Provided Methods§

Source

fn ok_or_invalid_data<C, F>(self, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Unwrap self into an Ok or an Error of the ErrorKind::InvalidData kind.

Source

fn ok_or_invalid_input<C, F>(self, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Unwrap self into an Ok or an Error of the ErrorKind::InvalidInput kind.

Source

fn ok_or_not_found<C, F>(self, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Unwrap self into an Ok or an Error of the ErrorKind::NotFound kind.

Source

fn ok_or_unexpected_eof<C, F>(self, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Unwrap self into an Ok or an Error of the ErrorKind::UnexpectedEof kind.

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.

Implementations on Foreign Types§

Source§

impl<T> IntoError<T> for Option<T>

Source§

fn ok_or_error<C, F>(self, kind: ErrorKind, f: F) -> Result<T, Error>
where C: ToString, F: FnOnce() -> C,

Implementors§