rok::core::stream
rok::core::stream - Stream / IntoStream / FromStream (stdlib
spec 2.8).
for await x in s polls s.poll_next(ref ctx) (after
s.into_stream() when s has no poll_next) like await, until it
is Ready(none).
The adapters (2.8.5) are provided methods of Stream returning the
structs below (stream::Map<S, U> is not iter::Map). throttle /
buffered / buffer_unordered wrap an async yield stream built by
a generic helper, the others poll their source directly.
Modules
Structs
AsyncStream
pub struct AsyncStream<T>Trait implementations 1
impl<T> Stream for AsyncStream<T>
Map
pub struct Map<SFilter
pub struct Filter<S>Trait implementations 1
impl<S: Stream> Stream for Filter<S>
Take
pub struct Take<S>Trait implementations 1
impl<S: Stream> Stream for Take<S>
Skip
pub struct Skip<S>Trait implementations 1
impl<S: Stream> Stream for Skip<S>
Throttle
pub struct Throttle<S>Trait implementations 1
impl<S: Stream> Stream for Throttle<S>
Buffered
pub struct Buffered<S>Trait implementations 1
impl<S: Stream> Stream for Buffered<S> where S::Item: Future
BufferUnordered
pub struct BufferUnordered<S>Trait implementations 1
impl<S: Stream> Stream for BufferUnordered<S> where S::Item: Future
Merge
pub struct Merge<S1Select
pub struct Select<S1Zip
pub struct Zip<S1TryAsyncStream
pub struct TryAsyncStream<TA throwing stream: errors come out of poll_next, so consume it with
try around for await steps (try await-style).
Traits
Stream
pub trait Streamtype Itemfn poll_next(ref self, ref ctx: Context) -> Poll<Item | none>const fn map<U>(self, f: fn(Item) -> U) -> Map<Selffof each item.const fn filter(self, pred: fn(Item) -> bool) -> Filter<Self>The items
predaccepts.const fn take(self, n: usize) -> Take<Self>At most the first
nitems.const fn skip(self, n: usize) -> Skip<Self>All but the first
nitems.fn throttle(self, dur: Duration) -> Throttle<Self>The items, at most one per
dur.fn buffered(self, n: usize) -> Buffered<Self> where Item: FutureThe outputs of a stream of futures, in stream order, running up to
nof them at once.fn buffer_unordered(self, n: usize) -> BufferUnordered<Self> where Item: FutureLike
buffered, in completion order.async fn collect<C: FromStream<Item> = List<Item>>(self) -> CAll items gathered into a
FromStreamcollection (2.8.6); aListwhen the slot does not pick one.async fn for_each(self, f: fn(Item))fof each item, in order.
IntoStream
pub trait IntoStreamtype Itemtype IntoStream: Stream<Item = Item>fn into_stream(self) -> IntoStream
FromStream
pub trait FromStream<T>collect's target (2.8.6): a collection built from a stream's items.
async fn from_stream<S: IntoStream<Item = T>>(s: S) -> Self
Functions
merge
pub const fn merge<S1: StreamBoth streams' items as they come; ends when both have.
select
pub const fn select<S1: StreamLike merge, but ends as soon as either stream does.
zip
pub const fn zip<S1: StreamPairs of the two streams' items, until either ends.