pub trait StreamOperators<T: Element> {
Show 26 methods
// Required methods
fn accumulate(self: &Rc<Self>) -> Rc<dyn Stream<Vec<T>>>;
fn average(self: &Rc<Self>) -> Rc<dyn Stream<f64>>
where T: ToPrimitive;
fn buffer(self: &Rc<Self>, capacity: usize) -> Rc<dyn Stream<Vec<T>>>;
fn collect(self: &Rc<Self>) -> Rc<dyn Stream<Vec<ValueAt<T>>>>;
fn collapse<OUT>(self: &Rc<Self>) -> Rc<dyn Stream<OUT>>
where T: IntoIterator<Item = OUT>,
OUT: Element;
fn consume_async<FUT>(
self: &Rc<Self>,
func: Box<dyn FnOnce(Pin<Box<dyn FutStream<T>>>) -> FUT + Send>,
) -> Rc<dyn Node>
where T: Element + Send,
FUT: Future<Output = ()> + Send + 'static;
fn finally<F: FnOnce(T, &GraphState) + Clone + 'static>(
self: &Rc<Self>,
func: F,
) -> Rc<dyn Node>;
fn for_each(
self: &Rc<Self>,
func: impl Fn(T, NanoTime) + 'static,
) -> Rc<dyn Node>;
fn fold<OUT: Element>(
self: &Rc<Self>,
func: impl Fn(&mut OUT, T) + 'static,
) -> Rc<dyn Stream<OUT>>;
fn difference(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: Sub<Output = T>;
fn delay(self: &Rc<Self>, delay: Duration) -> Rc<dyn Stream<T>>
where T: Hash + Eq;
fn demux<K, F>(
self: &Rc<Self>,
capacity: usize,
func: F,
) -> (Vec<Rc<dyn Stream<T>>>, Overflow<T>)
where K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&T) -> (K, DemuxEvent) + 'static;
fn demux_it<K, F, U>(
self: &Rc<Self>,
capacity: usize,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)
where T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static;
fn demux_it_with_map<K, F, U>(
self: &Rc<Self>,
map: DemuxMap<K>,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)
where T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static;
fn distinct(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: PartialEq;
fn filter(
self: &Rc<Self>,
condition: Rc<dyn Stream<bool>>,
) -> Rc<dyn Stream<T>>;
fn filter_value(
self: &Rc<Self>,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn Stream<T>>;
fn limit(self: &Rc<Self>, limit: u32) -> Rc<dyn Stream<T>>;
fn logged(self: &Rc<Self>, label: &str, level: Level) -> Rc<dyn Stream<T>>;
fn map<OUT: Element>(
self: &Rc<Self>,
func: impl Fn(T) -> OUT + 'static,
) -> Rc<dyn Stream<OUT>>;
fn mapper<FUNC, OUT>(
self: &Rc<Self>,
func: FUNC,
) -> Rc<dyn Stream<TinyVec<[OUT; 1]>>>
where T: Element + Send,
OUT: Element + Send + Hash + Eq,
FUNC: FnOnce(Rc<dyn Stream<TinyVec<[T; 1]>>>) -> Rc<dyn Stream<OUT>> + Send + 'static;
fn not(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: Not<Output = T>;
fn reduce(
self: &Rc<Self>,
func: impl Fn(T, T) -> T + 'static,
) -> Rc<dyn Stream<T>>;
fn sample(self: &Rc<Self>, trigger: Rc<dyn Node>) -> Rc<dyn Stream<T>>;
fn print(self: &Rc<Self>) -> Rc<dyn Stream<T>>;
fn sum(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: Add<T, Output = T>;
}Expand description
A trait containing operators that can be applied to Streams. Used to support method chaining syntax.
Required Methods§
Sourcefn average(self: &Rc<Self>) -> Rc<dyn Stream<f64>>where
T: ToPrimitive,
fn average(self: &Rc<Self>) -> Rc<dyn Stream<f64>>where
T: ToPrimitive,
running average of source
Sourcefn buffer(self: &Rc<Self>, capacity: usize) -> Rc<dyn Stream<Vec<T>>>
fn buffer(self: &Rc<Self>, capacity: usize) -> Rc<dyn Stream<Vec<T>>>
Buffer the source stream. The buffer is automatically flushed on the last cycle;
Sourcefn collect(self: &Rc<Self>) -> Rc<dyn Stream<Vec<ValueAt<T>>>>
fn collect(self: &Rc<Self>) -> Rc<dyn Stream<Vec<ValueAt<T>>>>
Used to accumulate values, which can be retrieved after the graph has completed running. Useful for unit tests.
Sourcefn collapse<OUT>(self: &Rc<Self>) -> Rc<dyn Stream<OUT>>where
T: IntoIterator<Item = OUT>,
OUT: Element,
fn collapse<OUT>(self: &Rc<Self>) -> Rc<dyn Stream<OUT>>where
T: IntoIterator<Item = OUT>,
OUT: Element,
collapses a burst (i.e. IntoIter[T]) of ticks into a single tick [T].
Does not tick if burst is empty.
fn consume_async<FUT>( self: &Rc<Self>, func: Box<dyn FnOnce(Pin<Box<dyn FutStream<T>>>) -> FUT + Send>, ) -> Rc<dyn Node>
fn finally<F: FnOnce(T, &GraphState) + Clone + 'static>( self: &Rc<Self>, func: F, ) -> Rc<dyn Node>
Sourcefn for_each(
self: &Rc<Self>,
func: impl Fn(T, NanoTime) + 'static,
) -> Rc<dyn Node>
fn for_each( self: &Rc<Self>, func: impl Fn(T, NanoTime) + 'static, ) -> Rc<dyn Node>
executes supplied closure on each tick
fn fold<OUT: Element>( self: &Rc<Self>, func: impl Fn(&mut OUT, T) + 'static, ) -> Rc<dyn Stream<OUT>>
Sourcefn difference(self: &Rc<Self>) -> Rc<dyn Stream<T>>where
T: Sub<Output = T>,
fn difference(self: &Rc<Self>) -> Rc<dyn Stream<T>>where
T: Sub<Output = T>,
difference in it’s source from one cycle to the next
Sourcefn delay(self: &Rc<Self>, delay: Duration) -> Rc<dyn Stream<T>>
fn delay(self: &Rc<Self>, delay: Duration) -> Rc<dyn Stream<T>>
Propagates it’s source, delayed by the specified duration
Sourcefn demux<K, F>(
self: &Rc<Self>,
capacity: usize,
func: F,
) -> (Vec<Rc<dyn Stream<T>>>, Overflow<T>)
fn demux<K, F>( self: &Rc<Self>, capacity: usize, func: F, ) -> (Vec<Rc<dyn Stream<T>>>, Overflow<T>)
Demuxes its source into a Vec of n streams.
Sourcefn demux_it<K, F, U>(
self: &Rc<Self>,
capacity: usize,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)where
T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static,
fn demux_it<K, F, U>(
self: &Rc<Self>,
capacity: usize,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)where
T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static,
Demuxes its source into a vec of n streams, where source is IntoIterator For example demuxes Vec of U into n streams of Vec of U
Sourcefn demux_it_with_map<K, F, U>(
self: &Rc<Self>,
map: DemuxMap<K>,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)where
T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static,
fn demux_it_with_map<K, F, U>(
self: &Rc<Self>,
map: DemuxMap<K>,
func: F,
) -> (Vec<Rc<dyn Stream<TinyVec<[U; 1]>>>>, Overflow<TinyVec<[U; 1]>>)where
T: IntoIterator<Item = U>,
U: Element,
K: Hash + Eq + PartialEq + Debug + 'static,
F: Fn(&U) -> (K, DemuxEvent) + 'static,
Demuxes its source into a vec of n streams, where source is IntoIterator For example demuxes Vec of U into n streams of Vec of U
Sourcefn distinct(self: &Rc<Self>) -> Rc<dyn Stream<T>>where
T: PartialEq,
fn distinct(self: &Rc<Self>) -> Rc<dyn Stream<T>>where
T: PartialEq,
only propagates it’s source if it is changed
Sourcefn filter(self: &Rc<Self>, condition: Rc<dyn Stream<bool>>) -> Rc<dyn Stream<T>>
fn filter(self: &Rc<Self>, condition: Rc<dyn Stream<bool>>) -> Rc<dyn Stream<T>>
drops source contingent on supplied stream
Sourcefn filter_value(
self: &Rc<Self>,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn Stream<T>>
fn filter_value( self: &Rc<Self>, predicate: impl Fn(&T) -> bool + 'static, ) -> Rc<dyn Stream<T>>
drops source contingent on supplied predicate
Sourcefn logged(self: &Rc<Self>, label: &str, level: Level) -> Rc<dyn Stream<T>>
fn logged(self: &Rc<Self>, label: &str, level: Level) -> Rc<dyn Stream<T>>
logs source and propagates it
Sourcefn map<OUT: Element>(
self: &Rc<Self>,
func: impl Fn(T) -> OUT + 'static,
) -> Rc<dyn Stream<OUT>>
fn map<OUT: Element>( self: &Rc<Self>, func: impl Fn(T) -> OUT + 'static, ) -> Rc<dyn Stream<OUT>>
Map’s it’s source into a new Stream using the supplied closure.
Sourcefn mapper<FUNC, OUT>(
self: &Rc<Self>,
func: FUNC,
) -> Rc<dyn Stream<TinyVec<[OUT; 1]>>>
fn mapper<FUNC, OUT>( self: &Rc<Self>, func: FUNC, ) -> Rc<dyn Stream<TinyVec<[OUT; 1]>>>
Uses func to build graph, which is spawned on worker thread
fn reduce( self: &Rc<Self>, func: impl Fn(T, T) -> T + 'static, ) -> Rc<dyn Stream<T>>
Sourcefn sample(self: &Rc<Self>, trigger: Rc<dyn Node>) -> Rc<dyn Stream<T>>
fn sample(self: &Rc<Self>, trigger: Rc<dyn Node>) -> Rc<dyn Stream<T>>
samples it’s source on each tick of trigger
fn print(self: &Rc<Self>) -> Rc<dyn Stream<T>>
fn sum(self: &Rc<Self>) -> Rc<dyn Stream<T>>where
T: Add<T, Output = T>,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.