pub trait Task: Send + Sync {
// Required methods
fn id(&self) -> &str;
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<Context>,
) -> Pin<Box<dyn Future<Output = Result<TaskOutput, TaskError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn dependencies(&self) -> Vec<String> { ... }
fn priority(&self) -> u8 { ... }
}Expand description
A unit of work in the DAG.
Implementations must be Send + Sync because tasks are shared across worker
threads (Arc<dyn Task>) and executed concurrently. The default
Task::dependencies and Task::priority make leaf, normal-priority
tasks the zero-boilerplate case.
Required Methods§
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<Context>,
) -> Pin<Box<dyn Future<Output = Result<TaskOutput, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
ctx: Arc<Context>,
) -> Pin<Box<dyn Future<Output = Result<TaskOutput, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the task.
The returned future is run on the executor’s worker pool. Implementations
should periodically check Context::is_cancelled for long-running work.
Provided Methods§
Sourcefn dependencies(&self) -> Vec<String>
fn dependencies(&self) -> Vec<String>
Ids of tasks that must complete successfully before this one runs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".