use crate::errors::BackieError; use crate::runnable::BackgroundTask; use crate::store::TaskStore; use crate::task::NewTask; use std::sync::Arc; use std::time::Duration; #[derive(Clone)] pub struct Queue where S: TaskStore, { task_store: Arc, } impl Queue where S: TaskStore, { pub fn new(task_store: Arc) -> Self { Queue { task_store } } pub async fn enqueue(&self, background_task: BT) -> Result<(), BackieError> where BT: BackgroundTask, { self.task_store .create_task(NewTask::new(background_task, Duration::from_secs(10))?) .await?; Ok(()) } }