Skip to main content

BackgroundTask

Trait BackgroundTask 

Source
pub trait BackgroundTask: Sync + Send {
    // Required method
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        count: u32,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A unified trait for any task that can be run in the background.

Required Methods§

Source

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

Executes a single iteration of the task.

§Arguments
  • count - The current execution cycle number.
§Returns
  • Ok(true) if the task performed meaningful work and should be logged as “success”.
  • Ok(false) if the task was skipped or did no work.
  • Err(Error) if the task failed.

Implementors§