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.