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§
Sourcefn 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.
// 1, 2, 3, etc.
ticker(Duration::from_millis(10)).count();Sourcefn 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.
// 0, 1000000000, 2000000000, etc.
ticker(Duration::from_millis(10)).ticked_at();Sourcefn 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.
// 0, 1000000000, 2000000000, etc.
ticker(Duration::from_millis(10)).ticked_at_elapsed();Sourcefn produce<T: Element>(
self: &Rc<Self>,
func: impl Fn() -> T + 'static,
) -> Rc<dyn Stream<T>>
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");Sourcefn run(self: &Rc<Self>, run_mode: RunMode, run_to: RunFor) -> Result<()>
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(); // 3fn 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.