rokdocs
v0.1

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<S

    Filter

    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<S1

    Select

    pub struct Select<S1

    Zip

    pub struct Zip<S1

    TryAsyncStream

    pub struct TryAsyncStream<T

    A throwing stream: errors come out of poll_next, so consume it with try around for await steps (try await-style).

    Traits

    Stream

    pub trait Stream
    • type Item
    • fn poll_next(ref self, ref ctx: Context) -> Poll<Item | none>
    • const fn map<U>(self, f: fn(Item) -> U) -> Map<Self

      f of each item.

    • const fn filter(self, pred: fn(Item) -> bool) -> Filter<Self>

      The items pred accepts.

    • const fn take(self, n: usize) -> Take<Self>

      At most the first n items.

    • const fn skip(self, n: usize) -> Skip<Self>

      All but the first n items.

    • fn throttle(self, dur: Duration) -> Throttle<Self>

      The items, at most one per dur.

    • fn buffered(self, n: usize) -> Buffered<Self> where Item: Future

      The outputs of a stream of futures, in stream order, running up to n of them at once.

    • fn buffer_unordered(self, n: usize) -> BufferUnordered<Self> where Item: Future

      Like buffered, in completion order.

    • async fn collect<C: FromStream<Item> = List<Item>>(self) -> C

      All items gathered into a FromStream collection (2.8.6); a List when the slot does not pick one.

    • async fn for_each(self, f: fn(Item))

      f of each item, in order.

    IntoStream

    pub trait IntoStream
    • type Item
    • type 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: Stream

    Both streams' items as they come; ends when both have.

    select

    pub const fn select<S1: Stream

    Like merge, but ends as soon as either stream does.

    zip

    pub const fn zip<S1: Stream

    Pairs of the two streams' items, until either ends.