Skip to main content

TaskManagerTrait

Trait TaskManagerTrait 

Source
pub trait TaskManagerTrait: Send + Sync {
    // Required methods
    fn add(&self, task: Task) -> Layer2Result<TaskId>;
    fn get(&self, id: &TaskId) -> Option<Task>;
    fn update_status<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 TaskId,
        status: TaskStatus,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn cancel<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 TaskId,
    ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn next(&self) -> Option<Task>;
    fn count(&self) -> usize;
    fn count_by_status(&self, status: TaskStatus) -> usize;
    fn cleanup_completed(&self) -> usize;
}
Expand description

任务管理器接口

Required Methods§

Source

fn add(&self, task: Task) -> Layer2Result<TaskId>

添加任务

Source

fn get(&self, id: &TaskId) -> Option<Task>

获取任务

Source

fn update_status<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, status: TaskStatus, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

更新任务状态

Source

fn cancel<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Layer2Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

取消任务

Source

fn next(&self) -> Option<Task>

获取下一个可执行任务

Source

fn count(&self) -> usize

获取任务数量

Source

fn count_by_status(&self, status: TaskStatus) -> usize

获取特定状态的任务数量

Source

fn cleanup_completed(&self) -> usize

清理已完成任务

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§