Struct eventual::Stream [] [src]

#[must_use = "streams are lazy and do nothing unless consumed"]
pub struct Stream<T: Send + 'static, E: Send + 'static> {
    // some fields omitted
}

Methods

impl<T: Send + 'static, E: Send + 'static> Stream<T, E>

fn pair() -> (Sender<T, E>, Stream<T, E>)

Creates a new Stream, returning it with the associated Sender.

fn empty() -> Stream<T, E>

Returns a Stream that will immediately succeed with the supplied value.

use eventual::*;

let stream = Stream::<i32, &'static str>::empty();
assert!(stream.iter().next().is_none());

fn collect(self) -> Future<Vec<T>, E>

Asyncronously collects the items from the Stream, returning them sorted by order of arrival.

fn iter(self) -> StreamIter<T, E>

Synchronously iterate over the Stream

fn each<F: FnMut(T) + Send + 'static>(self, f: F) -> Future<(), E>

Sequentially yields each value to the supplied function. Returns a future representing the completion of the final yield.

fn filter<F: FnMut(&T) -> bool + Send + 'static>(self, f: F) -> Stream<T, E>

Returns a new stream containing the values of the original stream that match the given predicate.

fn map<F: FnMut(T) -> U + Send + 'static, U: Send + 'static>(self, f: F) -> Stream<U, E>

Returns a new stream representing the application of the specified function to each value of the original stream.

fn map_async<F, U>(self, action: F) -> Stream<U::Value, E> where F: FnMut(T) -> U + Send + 'static, U: Async<Error=E>

Returns a new stream representing the application of the specified function to each value of the original stream. Each iteration waits for the async result of the mapping to realize before continuing on to the next value.

fn map_err<F, U>(self, f: F) -> Stream<T, U> where F: FnOnce(E) -> U + Send + 'static, U: Send + 'static

Returns a new stream with an identical sequence of values as the original. If the original stream errors, apply the given function on the error and use the result as the error of the new stream.

fn process<F, U>(self, in_flight: usize, f: F) -> Stream<U::Value, E> where F: FnMut(T) -> U + Send + 'static, U: Async<Error=E>

fn reduce<F: Fn(U, T) -> U + Send + 'static, U: Send + 'static>(self, init: U, f: F) -> Future<U, E>

Aggregate all the values of the stream by applying the given function to each value and the result of the previous application. The first iteration is seeded with the given initial value.

Returns a future that will be completed with the result of the final iteration.

fn reduce_async<F, U, X>(self, init: X, action: F) -> Future<X, E> where F: Fn(X, T) -> U + Send + 'static, U: Async<Value=X, Error=E>, X: Send + 'static

Aggregate all the values of the stream by applying the given function to each value and the realized result of the previous application. The first iteration is seeded with the given initial value.

Returns a future that will be completed with the result of the final iteration.

fn take(self, n: u64) -> Stream<T, E>

Returns a stream representing the n first values of the original stream.

fn take_while<F>(self, _f: F) -> Stream<T, E> where F: Fn(&T) -> bool + Send + 'static

fn take_until<A>(self, cond: A) -> Stream<T, E> where A: Async<Error=E>

fn to_future(self) -> Future<Head<T, E>, E>

Trait Implementations

impl<T: Send + 'static, E: Send + 'static> Async for Stream<T, E>

type Value = Head<T, E>

type Error = E

type Cancel = Receipt<Stream<T, E>>

fn is_ready(&self) -> bool

fn is_err(&self) -> bool

fn poll(self) -> Result<AsyncResult<Head<T, E>, E>, Stream<T, E>>

fn ready<F: FnOnce(Stream<T, E>) + Send + 'static>(self, f: F) -> Receipt<Stream<T, E>>

fn await(self) -> AsyncResult<Head<T, E>, E>

fn expect(self) -> AsyncResult<Self::Value, Self::Error>

fn receive<F>(self, f: F) where F: FnOnce(AsyncResult<Self::Value, Self::Error>) + Send + 'static

fn fire(self)

fn and<U: Async<Error=Self::Error>>(self, next: U) -> Future<U::Value, Self::Error>

fn and_then<F, U: Async<Error=Self::Error>>(self, f: F) -> Future<U::Value, Self::Error> where F: FnOnce(Self::Value) -> U + Send + 'static, U::Value: Send + 'static

fn or<A>(self, alt: A) -> Future<Self::Value, A::Error> where A: Async<Value=Self::Value>

fn or_else<F, A>(self, f: F) -> Future<Self::Value, A::Error> where F: FnOnce(Self::Error) -> A + Send + 'static, A: Async<Value=Self::Value>

impl<T: Send + 'static, E: Send + 'static> Pair for Stream<T, E>

type Tx = Sender<T, E>

fn pair() -> (Sender<T, E>, Stream<T, E>)

impl<T: Send + 'static, E: Send + 'static> Debug for Stream<T, E>

fn fmt(&self, fmt: &mut Formatter) -> Result

impl<T: Send + 'static, E: Send + 'static> Drop for Stream<T, E>

fn drop(&mut self)

impl<T: Send + 'static, E: Send + 'static> Source for Stream<T, E>

type Value = T

type Error = E

fn send_all<E2: Send + 'static>(self, sender: Sender<T, E2>) -> Future<Sender<T, E2>, (E, Sender<T, E2>)>