Trait jstream_ext::JTryStreamExt[][src]

pub trait JTryStreamExt: TryStream + Sized {
    fn try_first(self) -> TryStreamNth<Self>

Notable traits for TryStreamNth<S>

impl<S> Future for TryStreamNth<S> where
    S: TryStream, 
type Output = Result<Option<S::Ok>, S::Error>;
{ ... }
fn try_nth(self, n: usize) -> TryStreamNth<Self>

Notable traits for TryStreamNth<S>

impl<S> Future for TryStreamNth<S> where
    S: TryStream, 
type Output = Result<Option<S::Ok>, S::Error>;
{ ... }
fn try_filter_map_ok<F, R>(self, predicate: F) -> TryFilterMapOk<Self, F, R>
    where
        F: FnMut(Self::Ok) -> Option<R>
, { ... }
fn try_dedup(self) -> TryDedupStream<Self>
    where
        Self::Ok: Hash
, { ... }
fn fuse_on_fail(self) -> FuseOnFail<Self> { ... }
fn try_fold_mut<T, F, Fut>(
        self,
        initial: T,
        handler: F
    ) -> TryFoldMut<Self, T, F, Fut>

Notable traits for TryFoldMut<S, T, F, Fut>

impl<S, T, F, Fut> Future for TryFoldMut<S, T, F, Fut> where
    S: TryStream + FusedStream,
    F: FnMut(&mut T, S::Ok) -> Fut,
    Fut: TryFuture<Ok = (), Error = S::Error>, 
type Output = Result<T, S::Error>;

    where
        Self: FusedStream,
        F: FnMut(&mut T, Self::Ok) -> Fut,
        Fut: TryFuture<Ok = (), Error = Self::Error>
, { ... } }

Extensions to the TryStream type which aren't already covered by the included TryStreamExt.

This is implemented using a blanket impl for all TryStream implementors (which means any Stream that emits a Result).

Provided methods

fn try_first(self) -> TryStreamNth<Self>

Notable traits for TryStreamNth<S>

impl<S> Future for TryStreamNth<S> where
    S: TryStream, 
type Output = Result<Option<S::Ok>, S::Error>;
[src]

Turn this TryStream into a TryFuture which gives the first item emitted by this stream (in the form of an Option, because the stream doesn't necessarily have to emit anything).

fn try_nth(self, n: usize) -> TryStreamNth<Self>

Notable traits for TryStreamNth<S>

impl<S> Future for TryStreamNth<S> where
    S: TryStream, 
type Output = Result<Option<S::Ok>, S::Error>;
[src]

Turn this TryStream into a TryFuture which gives the nth item emitted by this stream (in the form of an Option, because the stream doesn't have to emit enough items to reach the index n).

It will only emit exactly the n'th item. If the stream completes before the nth item is reached, then the future will emit a value of None.

Any errors encountered while reaching nth item will be immediately returned.

The future emits a value of type Result<Option<Self::Ok>, Self::Error>

fn try_filter_map_ok<F, R>(self, predicate: F) -> TryFilterMapOk<Self, F, R> where
    F: FnMut(Self::Ok) -> Option<R>, 
[src]

filter+map on the Self::Ok value of this stream.

This stream, with the item type Result<Self::Ok, Self::Error>, can be converted to a stream which skips some values of Self::Ok and otherwise transforms non-skipped values to a new type T, giving a new stream with item type Result<T, Self::Error>.

If the current stream emits an Ok(Self::Ok) value, then the function passed to this method will be called to transform it to an Ok(T) message.

If the current stream emits some error by emitting the message Err(Self::Error), then this message will be passed straight-through.

fn try_dedup(self) -> TryDedupStream<Self> where
    Self::Ok: Hash
[src]

Given some stream where the Self::Ok type is Hash, then this method will allow you to "de-duplicate" that stream.

This is implemented by storing the hash (a u64 value) of the Self::Ok messages in a HashSet<u64> internally. If an item is emitted, it's hash is computed, and if the hash has been seen before, then the item is skipped.

Any error items will not be checked for duplication, and will simply be emitted by the modified "de-duplicated" stream.

fn fuse_on_fail(self) -> FuseOnFail<Self>[src]

If an Err(Self::Error) item is emitted from the stream, then panic on further calls to this stream's try_poll_next method, and also implement FusedStream for this stream (even if the current stream doesn't actually implement FusedStream).

fn try_fold_mut<T, F, Fut>(
    self,
    initial: T,
    handler: F
) -> TryFoldMut<Self, T, F, Fut>

Notable traits for TryFoldMut<S, T, F, Fut>

impl<S, T, F, Fut> Future for TryFoldMut<S, T, F, Fut> where
    S: TryStream + FusedStream,
    F: FnMut(&mut T, S::Ok) -> Fut,
    Fut: TryFuture<Ok = (), Error = S::Error>, 
type Output = Result<T, S::Error>;
where
    Self: FusedStream,
    F: FnMut(&mut T, Self::Ok) -> Fut,
    Fut: TryFuture<Ok = (), Error = Self::Error>, 
[src]

Given some initial value of a type T, and some function which accepts &mut T and Self::Ok and returns a Future<Output=Result<(), Self::Error>>, this stream can be converted into a Future<Output=Result<T, Self::Error>>.

The purpose of this method is basically "fold, but with mutable references, instead of moving the value."

Most implementations will not actually need to return a Future in the handler function, but it is required to be a Future to support rare use-cases where async code must be executed to update the T. In the common case, you can just use an async move block to turn your non-async code into a Future, or you can use futures::future::ready to construct a ready Future returning Ok(()).

If the source stream ever emits an Err(Self::Error) item, then that causes this future to immediately emit that same message. Otherwise, the returned future completes when the stream completes.

If the stream emits no items, then the initial value of T passed as the first parameter to this method is emitted as Ok(T).

Loading content...

Implementors

impl<T> JTryStreamExt for T where
    T: TryStream + Sized
[src]

Loading content...