Task

Trait Task 

Source
pub trait Task: Send + Sync {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = TaskResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn task_type(&self) -> &'static str;
    fn task_id(&self) -> String;

    // Provided methods
    fn estimated_duration(&self) -> Option<Duration> { ... }
    fn description(&self) -> String { ... }
}
Expand description

Trait defining a unit of work that can be executed asynchronously.

All tasks in the parallel processing system must implement this trait to provide execution logic and metadata.

Required Methods§

Source

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

Executes the task and returns the result.

Source

fn task_type(&self) -> &'static str

Returns the type identifier for this task.

Source

fn task_id(&self) -> String

Returns a unique identifier for this specific task instance.

Provided Methods§

Source

fn estimated_duration(&self) -> Option<Duration>

Returns an estimated duration for the task execution.

Source

fn description(&self) -> String

Returns a human-readable description of the task.

Implementors§