Trait ServiceTask

Source
pub trait ServiceTask: Sync + Send {
    // Required method
    fn run<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn description(&self) -> String { ... }
}

Required Methods§

Source

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

Executes a single iteration of the task. This method is called repeatedly at the specified interval until shutdown or task completion.

§Returns
  • None or Some(false) - Task completed normally, continue running the service
  • Some(true) - Task completed and requests service shutdown

Provided Methods§

Source

fn description(&self) -> String

Returns a human-readable description of the task for logging and monitoring. Implementations should provide meaningful descriptions of their purpose.

§Returns
  • String describing the task’s purpose, default is “unknown”

Implementors§