pub struct TaskPersistenceManager { /* private fields */ }Expand description
Manages task persistence using a SQLite database
This struct provides methods for saving and loading tasks from a SQLite database, ensuring task data survives between application restarts.
Implementations§
Source§impl TaskPersistenceManager
impl TaskPersistenceManager
Sourcepub async fn new<P: AsRef<Path>>(
database_path: P,
) -> Result<Self, SchedulerError>
pub async fn new<P: AsRef<Path>>( database_path: P, ) -> Result<Self, SchedulerError>
Creates a new persistence manager with the specified database
This method initializes the database connection and creates the necessary tables if they don’t exist.
§Arguments
database_path- Path to the SQLite database file
§Returns
Ok(TaskPersistenceManager)- Successfully created managerErr(SchedulerError)- If database initialization fails
Sourcepub async fn get_task(
&self,
task_id: &str,
) -> Result<Option<PersistableTask>, SchedulerError>
pub async fn get_task( &self, task_id: &str, ) -> Result<Option<PersistableTask>, SchedulerError>
Sourcepub async fn list_tasks(&self) -> Result<Vec<PersistableTask>, SchedulerError>
pub async fn list_tasks(&self) -> Result<Vec<PersistableTask>, SchedulerError>
Lists all tasks stored in the database
This method retrieves all tasks currently stored in the database.
§Returns
Ok(Vec<PersistableTask>)- List of all stored tasksErr(SchedulerError)- If the retrieval operation fails
Sourcepub async fn delete_task(&self, task_id: &str) -> Result<(), SchedulerError>
pub async fn delete_task(&self, task_id: &str) -> Result<(), SchedulerError>
Sourcepub async fn clear_tasks(&self) -> Result<(), SchedulerError>
pub async fn clear_tasks(&self) -> Result<(), SchedulerError>
Removes all tasks from the database
This method deletes all stored tasks, effectively resetting the persistence store.
§Returns
Ok(())- All tasks were cleared successfullyErr(SchedulerError)- If the clear operation fails
Auto Trait Implementations§
impl Freeze for TaskPersistenceManager
impl !RefUnwindSafe for TaskPersistenceManager
impl Send for TaskPersistenceManager
impl Sync for TaskPersistenceManager
impl Unpin for TaskPersistenceManager
impl !UnwindSafe for TaskPersistenceManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more