NodeOperators

Trait NodeOperators 

Source
pub trait NodeOperators {
    // Required methods
    fn count(self: &Rc<Self>) -> Rc<dyn Stream<u64>>;
    fn ticked_at(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>;
    fn ticked_at_elapsed(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>;
    fn produce<T: Element>(
        self: &Rc<Self>,
        func: impl Fn() -> T + 'static,
    ) -> Rc<dyn Stream<T>>;
    fn run(self: &Rc<Self>, run_mode: RunMode, run_to: RunFor) -> Result<()>;
    fn into_graph(self: &Rc<Self>, run_mode: RunMode, run_for: RunFor) -> Graph;
}
Expand description

A trait containing operators that can be applied to Nodes. Used to support method chaining syntax.

Required Methods§

Source

fn count(self: &Rc<Self>) -> Rc<dyn Stream<u64>>

Running count of the number of times it’s source ticks.

// 1, 2, 3, etc.
ticker(Duration::from_millis(10)).count();
Source

fn ticked_at(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>

Emits the time of source ticks in nanos from unix epoch.

// 0, 1000000000, 2000000000, etc.
ticker(Duration::from_millis(10)).ticked_at();
Source

fn ticked_at_elapsed(self: &Rc<Self>) -> Rc<dyn Stream<NanoTime>>

Emits the time of source ticks relative to the start.

// 0, 1000000000, 2000000000, etc.
ticker(Duration::from_millis(10)).ticked_at_elapsed();
Source

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

Emits the result of supplied closure on each upstream tick.

/// "hello world", "hello world", etc.
ticker(Duration::from_millis(10)).produce(|| "hello, world");
Source

fn run(self: &Rc<Self>, run_mode: RunMode, run_to: RunFor) -> Result<()>

Shortcut for Graph::run i.e. initialise and execute the graph.

let count = ticker(Duration::from_millis(1))
    .count();
count.run(RunMode::HistoricalFrom(NanoTime::ZERO), RunFor::Cycles(3))
    .unwrap();
count.peek_value(); // 3
Source

fn into_graph(self: &Rc<Self>, run_mode: RunMode, run_for: RunFor) -> Graph

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§