(&self)
| 355 | } |
| 356 | |
| 357 | pub async fn list_tasks(&self) -> Result<Vec<Task>, Box<dyn std::error::Error + Send + Sync>> { |
| 358 | let conn = Arc::clone(&self.conn); |
| 359 | tokio::task::spawn_blocking(move || { |
| 360 | let conn = conn.lock().map_err(|e| format!("Lock error: {e}"))?; |
| 361 | let mut stmt = conn.prepare("SELECT * FROM tasks ORDER BY created_at")?; |
| 362 | let tasks = stmt |
| 363 | .query_map([], row_to_task)? |
| 364 | .collect::<rusqlite::Result<Vec<_>>>()?; |
| 365 | Ok(tasks) |
| 366 | }) |
| 367 | .await? |
| 368 | } |
| 369 | |
| 370 | pub async fn delete_task( |
| 371 | &self, |
no outgoing calls