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]

[src]

Makes a new error instance.

[src]

Gets the immutable reference of the state of this AsyncError.

[src]

Gets the mutable reference of the state of this AsyncError.

[src]

Converts this AsyncError into the underlying state T.

[src]

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

[src]

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

[src]

Converts this AsyncError into the underlying error E.

[src]

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

[src]

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]

[src]

Formats the value using the given formatter.

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

[src]

Formats the value using the given formatter. Read more

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

[src]

A short description of the error. Read more

[src]

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