pub struct Stream<T: Send + 'static, E: Send + 'static> { /* private fields */ }
Implementations§
Source§impl<T: Send + 'static, E: Send + 'static> Stream<T, E>
impl<T: Send + 'static, E: Send + 'static> Stream<T, E>
Sourcepub fn pair() -> (Sender<T, E>, Stream<T, E>)
pub fn pair() -> (Sender<T, E>, Stream<T, E>)
Creates a new Stream
, returning it with the associated Sender
.
Sourcepub fn empty() -> Stream<T, E>
pub 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());
Sourcepub fn collect(self) -> Future<Vec<T>, E>
pub fn collect(self) -> Future<Vec<T>, E>
Asyncronously collects the items from the Stream
, returning them sorted by order of
arrival.
Sourcepub fn iter(self) -> StreamIter<T, E> ⓘ
pub fn iter(self) -> StreamIter<T, E> ⓘ
Synchronously iterate over the Stream
Sourcepub fn each<F: FnMut(T) + Send + 'static>(self, f: F) -> Future<(), E>
pub 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.
Sourcepub fn filter<F: FnMut(&T) -> bool + Send + 'static>(self, f: F) -> Stream<T, E>
pub 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.
Sourcepub fn map<F: FnMut(T) -> U + Send + 'static, U: Send + 'static>(
self,
f: F,
) -> Stream<U, E>
pub 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.
Sourcepub fn map_async<F, U>(self, action: F) -> Stream<U::Value, E>
pub fn map_async<F, U>(self, action: F) -> Stream<U::Value, 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.
Sourcepub fn map_err<F, U>(self, f: F) -> Stream<T, U>
pub fn map_err<F, U>(self, f: F) -> Stream<T, U>
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.
pub fn process<F, U>(self, in_flight: usize, f: F) -> Stream<U::Value, E>
Sourcepub fn reduce<F: Fn(U, T) -> U + Send + 'static, U: Send + 'static>(
self,
init: U,
f: F,
) -> Future<U, E>
pub 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.
Sourcepub fn reduce_async<F, U, X>(self, init: X, action: F) -> Future<X, E>
pub fn reduce_async<F, U, X>(self, init: X, action: F) -> Future<X, E>
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.
Sourcepub fn take(self, n: u64) -> Stream<T, E>
pub fn take(self, n: u64) -> Stream<T, E>
Returns a stream representing the n
first values of the original
stream.