Trait Task

Source
pub trait Task<CONTEXT: Send + Sync, ERROR: Error + Send + Sync, RESOURCE: Clone + Debug + DeserializeOwned + Resource<DynamicType = ()> + Send + Sync>: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn run(
        &self,
        res: Arc<RESOURCE>,
        ctx: Arc<CONTEXT>,
    ) -> impl Future<Output = Result<TaskStatus, ERROR>> + Send;
}
Expand description

A task.

Required Methods§

Source

fn name(&self) -> &str

Name of the task.

Source

fn run( &self, res: Arc<RESOURCE>, ctx: Arc<CONTEXT>, ) -> impl Future<Output = Result<TaskStatus, ERROR>> + Send

Run the task. Arguments:

  • res: the resource
  • ctx: the context of the application

It should return TaskStatus::Completed if the task is done and TaskStatus::InProgress if it is not.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§