Struct eventual::Stream
[−]
[src]
#[must_use = "streams are lazy and do nothing unless consumed"]pub struct Stream<T: Send + 'static, E: Send + 'static> { /* fields omitted */ }
Methods
impl<T: Send + 'static, E: Send + 'static> Stream<T, E>
[src]
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>
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>,
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,
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>,
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>
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,
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,
F: Fn(&T) -> bool + Send + 'static,
fn take_until<A>(self, cond: A) -> Stream<T, E> where
A: Async<Error = E>,
A: Async<Error = E>,
fn to_future(self) -> Future<Option<(T, Stream<T, E>)>, E>
Trait Implementations
impl<T: Send + 'static, E: Send + 'static> Async for Stream<T, E>
[src]
type Value = Option<(T, Stream<T, E>)>
type Error = E
type Cancel = Receipt<Stream<T, E>>
fn is_ready(&self) -> bool
Returns true if expect
will succeed.
fn is_err(&self) -> bool
Returns true if the async value is ready and has failed
fn poll(self) -> Result<AsyncResult<Option<(T, Stream<T, E>)>, E>, Stream<T, E>>
Get the underlying value if present
fn ready<F: FnOnce(Stream<T, E>) + Send + 'static>(
self,
f: F
) -> Receipt<Stream<T, E>>
self,
f: F
) -> Receipt<Stream<T, E>>
Invokes the given function when the Async instance is ready to be consumed. Read more
fn await(self) -> AsyncResult<Option<(T, Stream<T, E>)>, E>
Blocks the thread until the async value is complete and returns the result. Read more
fn expect(self) -> AsyncResult<Self::Value, Self::Error>
Get the underlying value if present, panic otherwise
fn receive<F>(self, f: F) where
F: FnOnce(AsyncResult<Self::Value, Self::Error>) + Send + 'static,
F: FnOnce(AsyncResult<Self::Value, Self::Error>) + Send + 'static,
Invoke the callback with the resolved Async
result.
fn fire(self)
Trigger the computation without waiting for the result
fn and<U: Async<Error = Self::Error>>(
self,
next: U
) -> Future<U::Value, Self::Error>
self,
next: U
) -> Future<U::Value, Self::Error>
This method returns a future whose completion value depends on the completion value of the original future. Read more
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,
self,
f: F
) -> Future<U::Value, Self::Error> where
F: FnOnce(Self::Value) -> U + Send + 'static,
U::Value: Send + 'static,
This method returns a future whose completion value depends on the completion value of the original future. Read more
fn or<A>(self, alt: A) -> Future<Self::Value, A::Error> where
A: Async<Value = Self::Value>,
A: Async<Value = Self::Value>,
This method returns a future whose completion value depends on the completion value of the original future. Read more
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>,
F: FnOnce(Self::Error) -> A + Send + 'static,
A: Async<Value = Self::Value>,
This method returns a future whose completion value depends on the completion value of the original future. Read more