Skip to main content

Runnable

Trait Runnable 

Source
pub trait Runnable {
    // Provided method
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = SimResult> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

The Runnable trait defines any active functionality that is spawned by a component.

This is a trait that defines an async function and therefore currently needs to use the #[async_trait(?Send)] decorator that converts it to a pinned boxed result. A basic implementation of the trait looks like:

#[async_trait(?Send)]
pub trait Runnable {
    async fn run(&self) -> SimResult {
        Ok(())
    }
}

A default implementation is provided for any compoment that doesn’t have any active behaviour.

Provided Methods§

Source

fn run<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = SimResult> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provides the method that defines the active element of this component.

Default implementation is to do nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§