Skip to main content

TaskRunner

Trait TaskRunner 

Source
pub trait TaskRunner:
    Send
    + Sync
    + 'static {
    type Output: Send + 'static;

    // Required method
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for implementing custom task runners.

Users implement this trait to define what their scheduled task does. The task runner is executed when the scheduled time arrives.

Required Associated Types§

Source

type Output: Send + 'static

The output type produced by the task runner.

Required Methods§

Source

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

Executes the task.

§Returns
  • Ok(Self::Output) - On successful execution
  • Err(Box<dyn std::error::Error + Send + Sync>) - On failure

Implementors§