Trait par_stream::TryStreamExt
source · [−]pub trait TryStreamExt where
Self: TryStream, {
fn try_enumerate(self) -> TryEnumerate<Self, Self::Ok, Self::Error>;
fn take_until_error(self) -> TakeUntilError<Self, Self::Ok, Self::Error>;
fn catch_error(self) -> (ErrorNotify<Self::Error>, CatchError<Self>);
fn try_stateful_then<B, U, F, Fut>(
self,
init: B,
f: F
) -> TryStatefulThen<Self, B, Self::Ok, U, Self::Error, F, Fut>
where
F: FnMut(B, Self::Ok) -> Fut,
Fut: Future<Output = Result<Option<(B, U)>, Self::Error>>;
fn try_stateful_map<B, U, F>(
self,
init: B,
f: F
) -> TryStatefulMap<Self, B, Self::Ok, U, Self::Error, F>
where
F: FnMut(B, Self::Ok) -> Result<Option<(B, U)>, Self::Error>;
}
Expand description
The trait extends TryStream types with combinators.
Required methods
fn try_enumerate(self) -> TryEnumerate<Self, Self::Ok, Self::Error>
fn try_enumerate(self) -> TryEnumerate<Self, Self::Ok, Self::Error>
Create a fallible stream that gives the current iteration count.
Overflow Behavior
The method does no guarding against overflows, so enumerating more than usize::MAX
elements either produces the wrong result or panics. If debug assertions are enabled, a panic is guaranteed.
Panics
The returned iterator might panic if the to-be-returned index would overflow a usize
.
fn take_until_error(self) -> TakeUntilError<Self, Self::Ok, Self::Error>
fn take_until_error(self) -> TakeUntilError<Self, Self::Ok, Self::Error>
Takes elements until an Err(_)
.
fn catch_error(self) -> (ErrorNotify<Self::Error>, CatchError<Self>)
fn catch_error(self) -> (ErrorNotify<Self::Error>, CatchError<Self>)
Split the stream of Result<T, E>
to a stream of T
and a future of Result<(), E>
.
The method returns (future, stream)
. If this combinator encoutners an Err
,
future.await
returns that error, and returned stream
fuses. If the input
stream is depleted without error, future.await
resolves to Ok(())
.
fn try_stateful_then<B, U, F, Fut>(
self,
init: B,
f: F
) -> TryStatefulThen<Self, B, Self::Ok, U, Self::Error, F, Fut> where
F: FnMut(B, Self::Ok) -> Fut,
Fut: Future<Output = Result<Option<(B, U)>, Self::Error>>,
fn try_stateful_then<B, U, F, Fut>(
self,
init: B,
f: F
) -> TryStatefulThen<Self, B, Self::Ok, U, Self::Error, F, Fut> where
F: FnMut(B, Self::Ok) -> Fut,
Fut: Future<Output = Result<Option<(B, U)>, Self::Error>>,
Similar to and_then but with a state.
fn try_stateful_map<B, U, F>(
self,
init: B,
f: F
) -> TryStatefulMap<Self, B, Self::Ok, U, Self::Error, F> where
F: FnMut(B, Self::Ok) -> Result<Option<(B, U)>, Self::Error>,
fn try_stateful_map<B, U, F>(
self,
init: B,
f: F
) -> TryStatefulMap<Self, B, Self::Ok, U, Self::Error, F> where
F: FnMut(B, Self::Ok) -> Result<Option<(B, U)>, Self::Error>,
Similar to map but with a state and is fallible.