Struct handy_async::error::AsyncError [] [src]

pub struct AsyncError<T, E> { /* fields omitted */ }

The error type for asynchronous operations.

This contains an actual error value and the state that caused the error.

Examples

use std::io::{empty, ErrorKind};
use handy_async::io::AsyncRead;
use handy_async::error::AsyncError;
use futures::Future;

// Trying to read any bytes from `empty()` stream will result in an `UnexpectedEof` error.
let e: AsyncError<_, _> = empty().async_read_non_empty([0]).wait().err().unwrap();
assert_eq!(e.error_ref().kind(), ErrorKind::UnexpectedEof);

Methods

impl<T, E> AsyncError<T, E> where
    E: Error
[src]

Makes a new error instance.

Gets the immutable reference of the state of this AsyncError.

Gets the mutable reference of the state of this AsyncError.

Converts this AsyncError into the underlying state T.

Gets the immutable reference of the actual error of this AsyncError.

Gets the mutable reference of the actual error of this AsyncError.

Converts this AsyncError into the underlying error E.

Unwraps this AsyncError, returing the underlying state and error as (T, E).

Maps a AsyncError<T, E> to AsyncError<U, E> by applying a function F to the contained state.

Examples

use std::io::{Error, ErrorKind};
use handy_async::error::AsyncError;

let error = AsyncError::new("dummy_state", Error::new(ErrorKind::Other, ""));
assert_eq!(error.state_ref(), &"dummy_state");

let error = error.map_state(|s| s.len());
assert_eq!(error.state_ref(), &11);

Trait Implementations

impl<T, E> Debug for AsyncError<T, E> where
    E: Error
[src]

Formats the value using the given formatter.

impl<T, E> Display for AsyncError<T, E> where
    E: Error
[src]

Formats the value using the given formatter. Read more

impl<T, E> Error for AsyncError<T, E> where
    E: Error
[src]

A short description of the error. Read more

The lower-level cause of this error, if any. Read more