Struct Stream

Source
pub struct Stream<T: Send + 'static, E: Send + 'static> { /* private fields */ }

Implementations§

Source§

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

Source

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

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

Source

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());
Source

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

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

Source

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

Synchronously iterate over the Stream

Source

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.

Source

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.

Source

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.

Source

pub 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.

Source

pub 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.

Source

pub 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>,

Source

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.

Source

pub 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.

Source

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

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

Source

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

Source

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

Source

pub fn to_future(self) -> Future<Option<(T, Stream<T, E>)>, E>

Trait Implementations§

Source§

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

Source§

type Value = Option<(T, Stream<T, E>)>

Source§

type Error = E

Source§

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

Source§

fn is_ready(&self) -> bool

Returns true if expect will succeed.
Source§

fn is_err(&self) -> bool

Returns true if the async value is ready and has failed
Source§

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

Get the underlying value if present
Source§

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

Invokes the given function when the Async instance is ready to be consumed.
Source§

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

Blocks the thread until the async value is complete and returns the result.
Source§

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

Get the underlying value if present, panic otherwise
Source§

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

Invoke the callback with the resolved Async result.
Source§

fn fire(self)

Trigger the computation without waiting for the result
Source§

fn and<U: Async<Error = 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
Source§

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,

This method returns a future whose completion value depends on the completion value of the original future. Read more
Source§

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

This method returns a future whose completion value depends on the completion value of the original future. Read more
Source§

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

This method returns a future whose completion value depends on the completion value of the original future. Read more
Source§

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

Source§

fn cancel(self) -> Option<Stream<T, E>>

Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Source§

type Tx = Sender<T, E>

Source§

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

Auto Trait Implementations§

§

impl<T, E> Freeze for Stream<T, E>

§

impl<T, E> !RefUnwindSafe for Stream<T, E>

§

impl<T, E> Send for Stream<T, E>

§

impl<T, E> !Sync for Stream<T, E>

§

impl<T, E> Unpin for Stream<T, E>

§

impl<T, E> !UnwindSafe for Stream<T, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.