Struct frappe::Stream
[−]
[src]
pub struct Stream<T> { /* fields omitted */ }
A stream of discrete events sent over time.
All the objects that result from stream operations contain an internal reference to it's parent, so dropping intermediate temporary streams (like the ones created from chaining methods) won't break the chain.
Methods
impl<T> Stream<T>
[src]
impl<T: 'static> Stream<T>
[src]
fn map<F, R>(&self, f: F) -> Stream<R> where
F: Fn(MaybeOwned<T>) -> R + 'static,
R: 'static,
[src]
F: Fn(MaybeOwned<T>) -> R + 'static,
R: 'static,
Maps this stream into another stream using the provided function.
fn filter<F>(&self, pred: F) -> Self where
F: Fn(&T) -> bool + 'static,
[src]
F: Fn(&T) -> bool + 'static,
Creates a new stream that only contains the values where the predicate is true
.
fn filter_map<F, R>(&self, f: F) -> Stream<R> where
F: Fn(MaybeOwned<T>) -> Option<R> + 'static,
R: 'static,
[src]
F: Fn(MaybeOwned<T>) -> Option<R> + 'static,
R: 'static,
Filter and map a stream simultaneously.
fn merge(&self, other: &Stream<T>) -> Self
[src]
Creates a new stream that fires with the events from both streams.
fn merge_with<U, F1, F2, R>(
&self,
other: &Stream<U>,
f1: F1,
f2: F2
) -> Stream<R> where
F1: Fn(MaybeOwned<T>) -> R + 'static,
F2: Fn(MaybeOwned<U>) -> R + 'static,
U: 'static,
R: 'static,
[src]
&self,
other: &Stream<U>,
f1: F1,
f2: F2
) -> Stream<R> where
F1: Fn(MaybeOwned<T>) -> R + 'static,
F2: Fn(MaybeOwned<U>) -> R + 'static,
U: 'static,
R: 'static,
Merges two streams of different types using two functions that return the same type.
fn fold<A, F>(&self, initial: A, f: F) -> Signal<A> where
F: Fn(A, MaybeOwned<T>) -> A + 'static,
A: 'static,
[src]
F: Fn(A, MaybeOwned<T>) -> A + 'static,
A: 'static,
Accumulates the values sent over this stream.
The fold operation is done by taking the accumulator, consuming it's value, and then
putting back the transformed value. This avoids cloning, but if the closure panics it will
leave the storage empty, and then any sampling attempt on this object will panic until
someone puts back a value on it.
If this is undesirable, use Stream::fold_clone
instead.
fn fold_clone<A, F>(&self, initial: A, f: F) -> Signal<A> where
F: Fn(A, MaybeOwned<T>) -> A + 'static,
A: Clone + 'static,
[src]
F: Fn(A, MaybeOwned<T>) -> A + 'static,
A: Clone + 'static,
Folds the stream by cloning the accumulator.
This will clone the accumulator on every value processed, but if the closure panics, the storage will remain unchanged and later attempts at sampling will succeed like nothing happened.
fn map_n<F, R>(&self, f: F) -> Stream<R> where
F: Fn(MaybeOwned<T>, Sink<R>) + 'static,
R: 'static,
[src]
F: Fn(MaybeOwned<T>, Sink<R>) + 'static,
R: 'static,
Maps each stream event to 0..N
output values.
The closure must return it's value by sending it through the provided sink. Multiple values (or none) can be sent to the output stream this way.
This primitive is useful to construct asynchronous operations, since you can store the sink for later usage.
fn inspect<F>(self, f: F) -> Self where
F: Fn(MaybeOwned<T>) + 'static,
[src]
F: Fn(MaybeOwned<T>) + 'static,
Reads the values without modifying them.
This is meant to be used as a debugging tool and not to cause side effects.
impl<T: Clone + 'static> Stream<T>
[src]
fn hold(&self, initial: T) -> Signal<T>
[src]
Creates a Signal that holds the last value sent to this stream.
fn hold_if<F>(&self, initial: T, pred: F) -> Signal<T> where
F: Fn(&T) -> bool + 'static,
[src]
F: Fn(&T) -> bool + 'static,
Holds the last value in this stream where the predicate is true
.
fn collect<C>(&self) -> Signal<C> where
C: Default + Extend<T> + 'static,
[src]
C: Default + Extend<T> + 'static,
Creates a collection from the values of this stream.
fn as_channel(&self) -> Receiver<T>
[src]
Creates a channel and sends the stream events through it.
This doesn't create a strong reference to the parent stream, so the channel sender will be dropped when the stream is deleted.
impl<T: Clone + 'static> Stream<Option<T>>
[src]
fn filter_some(&self) -> Stream<T>
[src]
Filters a stream of Option
, returning the unwrapped Some
values
impl<T: SumType2 + Clone + 'static> Stream<T> where
T::Type1: 'static,
T::Type2: 'static,
[src]
T::Type1: 'static,
T::Type2: 'static,
fn filter_first(&self) -> Stream<T::Type1>
[src]
Creates a stream with only the first element of a sum type
fn filter_second(&self) -> Stream<T::Type2>
[src]
Creates a stream with only the second element of a sum type
fn split(&self) -> (Stream<T::Type1>, Stream<T::Type2>)
[src]
Splits a two element sum type stream into two streams with the unwrapped values
impl<T: 'static> Stream<Stream<T>>
[src]
fn switch(&self) -> Stream<T>
[src]
Listens to the events from the last stream sent to a nested stream
Trait Implementations
impl<T: Debug> Debug for Stream<T>
[src]
impl<T> Clone for Stream<T>
[src]
fn clone(&self) -> Self
[src]
Creates a copy of this stream that references the same event chain.
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more