Trait Codelet

Source
pub trait Codelet: Send {
    type Status: CodeletStatus;
    type Config: Config + Send;
    type Rx: RxBundle;
    type Tx: TxBundle;

    // Required method
    fn build_bundles(cfg: &Self::Config) -> (Self::Rx, Self::Tx);

    // Provided methods
    fn start(
        &mut self,
        _cx: &Context<'_, Self>,
        _rx: &mut Self::Rx,
        _tx: &mut Self::Tx,
    ) -> Result<Self::Status> { ... }
    fn stop(
        &mut self,
        _cx: &Context<'_, Self>,
        _rx: &mut Self::Rx,
        _tx: &mut Self::Tx,
    ) -> Result<Self::Status> { ... }
    fn step(
        &mut self,
        _cx: &Context<'_, Self>,
        _rx: &mut Self::Rx,
        _tx: &mut Self::Tx,
    ) -> Result<Self::Status> { ... }
    fn pause(&mut self) -> Result<Self::Status> { ... }
    fn resume(&mut self) -> Result<Self::Status> { ... }
}
Expand description

Codelets can be implemented by the user to execute work.

Required Associated Types§

Source

type Status: CodeletStatus

Status code used to indicate health of codelet

Source

type Config: Config + Send

Type used for configuration

Source

type Rx: RxBundle

Type holding all receiving (RX) endpoints

Source

type Tx: TxBundle

Type holding all transmitting (TX) endpoints

Required Methods§

Source

fn build_bundles(cfg: &Self::Config) -> (Self::Rx, Self::Tx)

Constructs channel bundles

Provided Methods§

Source

fn start( &mut self, _cx: &Context<'_, Self>, _rx: &mut Self::Rx, _tx: &mut Self::Tx, ) -> Result<Self::Status>

Start is guaranteed to be called first. Start may be called again after stop was called.

Source

fn stop( &mut self, _cx: &Context<'_, Self>, _rx: &mut Self::Rx, _tx: &mut Self::Tx, ) -> Result<Self::Status>

Stop is guaranteed to be called at the end if start was called.

Source

fn step( &mut self, _cx: &Context<'_, Self>, _rx: &mut Self::Rx, _tx: &mut Self::Tx, ) -> Result<Self::Status>

Step is executed periodically after the codelet is started and while it is not paused.

Source

fn pause(&mut self) -> Result<Self::Status>

Pause may be called to suspend stepping.

Source

fn resume(&mut self) -> Result<Self::Status>

Resume is called to resume stepping. Note that stop may also be called while the codelet is paused to stop the codelet completely instead of resuming stepping.

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§