Skip to main content

Runnable

Trait Runnable 

Source
pub trait Runnable:
    Send
    + Sync
    + 'static {
    // Required method
    fn run<'async_trait>(
        self: Arc<Self>,
        cancel: CancellationToken,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

Trait for gears that can run a long-running task. Note: take self by Arc to make the spawned future 'static and Send.

Required Methods§

Source

fn run<'async_trait>( self: Arc<Self>, cancel: CancellationToken, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,

Long-running loop. Must return when cancel is cancelled.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§