Stream

Trait Stream 

Source
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> Debug for dyn Stream<T>

Source§

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

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

impl<T> NodeOperators for dyn Stream<T>

Source§

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

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

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

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

Shortcut for Graph::run i.e. initialise and execute the graph. Read more
Source§

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,

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 demux<K, F>( self: &Rc<Self>, capacity: usize, func: F, ) -> (Vec<Rc<dyn Stream<T>>>, Overflow<T>)
where T: Element, 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 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>>
where T: Hash + Eq,

Propagates it’s source, delayed by the specified duration
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 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 finally<F: FnOnce(T, &GraphState) + Clone + 'static>( self: &Rc<Self>, func: F, ) -> Rc<dyn Node>

Source§

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

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 print(self: &Rc<Self>) -> Rc<dyn Stream<T>>

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 sum(self: &Rc<Self>) -> Rc<dyn Stream<T>>
where T: Add<T, Output = T>,

Implementations on Foreign Types§

Source§

impl<STREAM, T> Stream<T> for RefCell<STREAM>
where STREAM: StreamPeekRef<T> + 'static, T: Clone + 'static,

Implementors§