[−][src]Trait snafu::futures::TryStreamExt
Additions to TryStream
.
Required methods
fn context<C, E>(self, context: C) -> Context<Self, C, E> where
C: IntoError<E, Source = Self::Error> + Clone,
E: Error + ErrorCompat,
C: IntoError<E, Source = Self::Error> + Clone,
E: Error + ErrorCompat,
Extend a TryStream
's error with additional context-sensitive
information.
use futures::TryStream; use snafu::{futures::TryStreamExt, Snafu}; #[derive(Debug, Snafu)] enum Error { Authenticating { user_name: String, user_id: i32, source: ApiError, }, } fn example() -> impl TryStream<Ok = i32, Error = Error> { stock_prices().context(Authenticating { user_name: "admin", user_id: 42, }) } fn stock_prices() -> impl TryStream<Ok = 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: FnMut() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
F: FnMut() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
Extend a TryStream
's error with lazily-generated
context-sensitive information.
use futures::TryStream; use snafu::{futures::TryStreamExt, Snafu}; #[derive(Debug, Snafu)] enum Error { Authenticating { user_name: String, user_id: i32, source: ApiError, }, } fn example() -> impl TryStream<Ok = i32, Error = Error> { stock_prices().with_context(|| Authenticating { user_name: "admin", user_id: 42, }) } fn stock_prices() -> impl TryStream<Ok = 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<St> TryStreamExt for St where
St: TryStream,
[src]
St: TryStream,
fn context<C, E>(self, context: C) -> Context<Self, C, E> where
C: IntoError<E, Source = Self::Error> + Clone,
E: Error + ErrorCompat,
[src]
C: IntoError<E, Source = Self::Error> + Clone,
E: Error + ErrorCompat,
fn with_context<F, C, E>(self, context: F) -> WithContext<Self, F, E> where
F: FnMut() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,
[src]
F: FnMut() -> C,
C: IntoError<E, Source = Self::Error>,
E: Error + ErrorCompat,