StreamOperators

Trait StreamOperators 

Source
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§

Source

fn accumulate(self: &Rc<Self>) -> Rc<dyn Stream<Vec<T>>>

accumulate the source into a vector

Source

fn average(self: &Rc<Self>) -> Rc<dyn Stream<f64>>
where T: ToPrimitive,

running average of source

Source

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;

Source

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.

Source

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.

Source

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,

Source

fn finally<F: FnOnce(T, &GraphState) + Clone + 'static>( self: &Rc<Self>, func: F, ) -> Rc<dyn Node>

Source

fn for_each( self: &Rc<Self>, func: impl Fn(T, NanoTime) + 'static, ) -> Rc<dyn Node>

executes supplied closure on each tick

Source

fn fold<OUT: Element>( self: &Rc<Self>, func: impl Fn(&mut OUT, T) + 'static, ) -> Rc<dyn Stream<OUT>>

Source

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

Source

fn delay(self: &Rc<Self>, delay: Duration) -> Rc<dyn Stream<T>>
where T: Hash + Eq,

Propagates it’s source, delayed by the specified duration

Source

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,

Demuxes its source into a Vec of n streams.

Source

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

Source

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

Source

fn distinct(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: PartialEq,

only propagates it’s source if it is changed

Source

fn filter(self: &Rc<Self>, condition: Rc<dyn Stream<bool>>) -> Rc<dyn Stream<T>>

drops source contingent on supplied stream

Source

fn filter_value( self: &Rc<Self>, predicate: impl Fn(&T) -> bool + 'static, ) -> Rc<dyn Stream<T>>

drops source contingent on supplied predicate

Source

fn limit(self: &Rc<Self>, limit: u32) -> Rc<dyn Stream<T>>

propagates source up to limit times

Source

fn logged(self: &Rc<Self>, label: &str, level: Level) -> Rc<dyn Stream<T>>

logs source and propagates it

Source

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.

Source

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,

Uses func to build graph, which is spawned on worker thread

Source

fn not(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: Not<Output = T>,

negates it’s input

Source

fn reduce( self: &Rc<Self>, func: impl Fn(T, T) -> T + 'static, ) -> Rc<dyn Stream<T>>

Source

fn sample(self: &Rc<Self>, trigger: Rc<dyn Node>) -> Rc<dyn Stream<T>>

samples it’s source on each tick of trigger

Source

fn print(self: &Rc<Self>) -> Rc<dyn Stream<T>>

Source

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.

Implementors§

Source§

impl<T> StreamOperators<T> for dyn Stream<T>
where T: Element + 'static,