pub trait Stream<T>:
Node
+ StreamPeek<T>
+ AsNode { }Expand description
A Node which has some state that can peeked at.
Trait Implementations§
Source§impl<T> NodeOperators for dyn Stream<T>
impl<T> NodeOperators for dyn Stream<T>
Source§fn count(self: &Rc<Self>) -> Rc<dyn Stream<u64>>
fn count(self: &Rc<Self>) -> Rc<dyn Stream<u64>>
Running count of the number of times it’s source ticks. Read more
Source§fn ticked_at(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>
fn ticked_at(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>
Emits the time of source ticks in nanos from unix epoch. Read more
Source§fn ticked_at_elapsed(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>
fn ticked_at_elapsed(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>
Emits the time of source ticks relative to the start. Read more
Source§fn produce<OUT: Element>(
self: &Rc<Self>,
func: impl Fn() -> OUT + 'static,
) -> Rc<dyn Stream<OUT>>
fn produce<OUT: Element>( self: &Rc<Self>, func: impl Fn() -> OUT + 'static, ) -> Rc<dyn Stream<OUT>>
Emits the result of supplied closure on each upstream tick. Read more
Source§fn run(self: &Rc<Self>, run_mode: RunMode, run_for: RunFor) -> Result<()>
fn run(self: &Rc<Self>, run_mode: RunMode, run_for: RunFor) -> Result<()>
Shortcut for Graph::run i.e. initialise and execute the graph. Read more
fn into_graph(self: &Rc<Self>, run_mode: RunMode, run_for: RunFor) -> Graph
Source§impl<T> StreamOperators<T> for dyn Stream<T>where
T: Element + 'static,
impl<T> StreamOperators<T> for dyn Stream<T>where
T: Element + 'static,
Source§fn 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
Source§fn 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;
Source§fn 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.
Source§fn 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.
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>
Source§fn 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.
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,
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,
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 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
Source§fn delay(self: &Rc<Self>, duration: Duration) -> Rc<dyn Stream<T>>
fn delay(self: &Rc<Self>, duration: Duration) -> Rc<dyn Stream<T>>
Propagates it’s source, delayed by the specified duration
Source§fn 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
Source§fn 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
Source§fn 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
Source§fn 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
fn finally<F: FnOnce(T, &GraphState) + Clone + 'static>( self: &Rc<Self>, func: F, ) -> Rc<dyn Node>
fn fold<OUT: Element>( self: &Rc<Self>, func: impl Fn(&mut OUT, T) + 'static, ) -> Rc<dyn Stream<OUT>>
Source§fn limit(self: &Rc<Self>, limit: u32) -> Rc<dyn Stream<T>>
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>>
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>>
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]>>>
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 print(self: &Rc<Self>) -> Rc<dyn Stream<T>>
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>>
fn sample(self: &Rc<Self>, trigger: Rc<dyn Node>) -> Rc<dyn Stream<T>>
samples it’s source on each tick of trigger