Trait jstream_ext::JStreamExt [−][src]
Extensions to the Stream
type which aren't already covered in
StreamExt
.
This is implemented using a blanket impl for all Stream
implementors.
Provided methods
fn dedup(self) -> DedupStream<Self> where
Self::Item: Hash,
[src]
Self::Item: Hash,
Given some stream where the item is Hash
, return a stream which only emits the unique
items emitted by the source stream.
You can think of this as "de-duplicating" this stream. Only the first instance of every unique item will be emitted.
This is implemented by computing and storing the hash (a u64
value) in a HashSet
for
each item emitted by the stream.
fn fold_mut<T, F, Fut>(self, initial: T, handler: F) -> FoldMut<Self, T, F, Fut>ⓘ where
Self: FusedStream,
F: FnMut(&mut T, Self::Item) -> Fut,
Fut: Future<Output = ()>,
[src]
Self: FusedStream,
F: FnMut(&mut T, Self::Item) -> Fut,
Fut: Future<Output = ()>,
fold, but with mutable references.
Turns this stream into a Future<Output=T>
. You must provide some initial value of type T
,
and some function which accepts &mut T
and Self::Item
and returns Future<Output=()>
.
After all items are emitted by this stream, the current value of T
is emitted by the returned
future.
If the stream emits no values, then the initial value of T
is emitted.
fn first(self) -> StreamNth<Self>ⓘ
[src]
Turn this Stream
into a Future
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 nth(self, index: usize) -> StreamNth<Self>ⓘ
[src]
Turn this Stream
into a Future
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 n
th item
is reached, then the future will emit a value of None
.