pub trait TaskRepository<DB: Database>: DatabaseRepository<DB> {
// Required methods
fn create_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_pending_tasks<'life0, 'async_trait>(
&'life0 self,
limit: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<DbTask>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
status: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn complete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
result: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn fail_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
error: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn create_download_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbDownloadTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update_download_progress<'life0, 'async_trait>(
&'life0 self,
task_id: Uuid,
downloaded_size: i64,
progress_percent: f32,
speed_bps: i64,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_download_tasks_by_model<'life0, 'async_trait>(
&'life0 self,
model_id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<DbDownloadTask>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
任务管理数据库仓库
Required Methods§
Sourcefn create_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
创建任务
Sourcefn get_pending_tasks<'life0, 'async_trait>(
&'life0 self,
limit: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<DbTask>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_pending_tasks<'life0, 'async_trait>(
&'life0 self,
limit: Option<i64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<DbTask>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取待处理任务
Sourcefn update_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
status: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
status: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
更新任务状态
Sourcefn complete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
result: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
result: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
完成任务
Sourcefn fail_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
error: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fail_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task_id: Uuid,
error: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
失败任务
Sourcefn create_download_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbDownloadTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create_download_task<'life0, 'life1, 'async_trait>(
&'life0 self,
task: &'life1 DbDownloadTask,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
创建下载任务