Trait Node

Source
pub trait Node<ID: PartialEq>: Send {
    // Required methods
    fn get_id(&self) -> ID;
    fn get_update_delay_us(&self) -> u128;

    // Provided methods
    fn start(&mut self) { ... }
    fn update(&mut self) { ... }
    fn shutdown(&mut self) { ... }
}
Expand description

A Node represents a singular process that performs some singular purpose

Nodes should also all be given unique IDs so that they can be identified as trait objects.

Required Methods§

Source

fn get_id(&self) -> ID

Return the node’s ID

Source

fn get_update_delay_us(&self) -> u128

Return the node’s update rate (in us)

Provided Methods§

Source

fn start(&mut self)

Complete the necessary setup functionalities for a Node.

Note: this method is called on Start for the executor or (if the executor was not formally started) before the executor begins updating nodes.

Source

fn update(&mut self)

Update is called by the executor every get_update_delay microseconds.

This can be compared to Arduino’s void loop and should include the work completed by this node every “tick”.

Source

fn shutdown(&mut self)

When an executor is stopped or has finished executing nodes, it will call this method on all of its nodes so this should clean up any work the node needs to do.

Implementors§