Trait nri::comms::Controllable [-] [+] [src]

pub trait Controllable {
    fn setup(Sender<CmdFrom>) -> Self;
    fn step(&mut self) -> bool;
    fn teardown(&mut self);
}

A service that can be setup and torn down based on commands from a higher power.

Required Methods

fn setup(Sender<CmdFrom>) -> Self

Setup the service.

Should initialize any necessary libraries and devices. May be called more than once, but teardown() will be called in between.

fn step(&mut self) -> bool

Run one "step".

In the case of a device driver, this corresponds to gathering one frame or sample of data.

Return true if we should wait for a command from the supervisor thread before calling step() again. Return false to call step() again right away (unless there is a pending command).

fn teardown(&mut self)

Tear down the service.

Should shut down any necessary libraries or services. Either the program is exiting, or the service is just being paused (setup() could be called again).

Implementors