Trait TryStreamExt

Source
pub trait TryStreamExt
where Self: TryStream,
{ // Required methods 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§

Source

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.

Source

fn take_until_error(self) -> TakeUntilError<Self, Self::Ok, Self::Error>

Takes elements until an Err(_).

Source

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(()).

Source

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.

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, T, E> TryStreamExt for S
where S: Stream<Item = Result<T, E>>,