[−][src]Trait snafu::futures01::future::FutureExt
Additions to Future
.
Required methods
fn context<C, E>(self, context: C) -> Context<Self, C, E> where
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
Extend a Future
's error with additional context-sensitive
information.
use futures::Future; use snafu::{futures01::FutureExt, Snafu}; #[derive(Debug, Snafu)] enum Error { Authenticating { user_name: String, user_id: i32, source: ApiError, }, } fn example() -> impl Future<Item = i32, Error = Error> { another_function().context(Authenticating { user_name: "admin", user_id: 42, }) } fn another_function() -> impl Future<Item = i32, Error = ApiError> { /* ... */ }
Note that the context selector will call Into::into
on
each field, so the types are not required to exactly match.
fn with_context<F, C, E>(self, context: F) -> WithContext<Self, F, E> where
F: FnOnce() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
F: FnOnce() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
Extend a Future
's error with lazily-generated context-sensitive
information.
use futures::Future; use snafu::{futures01::FutureExt, Snafu}; #[derive(Debug, Snafu)] enum Error { Authenticating { user_name: String, user_id: i32, source: ApiError, }, } fn example() -> impl Future<Item = i32, Error = Error> { another_function().with_context(|| Authenticating { user_name: "admin".to_string(), user_id: 42, }) } fn another_function() -> impl Future<Item = i32, Error = ApiError> { /* ... */ }
Note that this may not be needed in many cases because the
context selector will call Into::into
on each field.
Implementors
impl<Fut> FutureExt for Fut where
Fut: Future,
[src]
Fut: Future,
fn context<C, E>(self, context: C) -> Context<Self, C, E> where
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
[src]
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
fn with_context<F, C, E>(self, context: F) -> WithContext<Self, F, E> where
F: FnOnce() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
[src]
F: FnOnce() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,