Expand description
Storage abstraction layer for task persistence.
This module defines the Storage trait and re-exports the two built-in
implementations:
| Type | Description |
|---|---|
JsonStorage | Persists tasks to a JSON file in the OS data directory |
InMemoryStorage | Stores tasks in memory — ideal for tests |
§Implementing a custom storage backend
Implement Storage to add your own persistence layer (SQLite, cloud
sync, encrypted file, etc.):
use anyhow::Result;
use rustodo::models::Task;
use rustodo::storage::Storage;
struct MyStorage;
impl Storage for MyStorage {
fn load(&self) -> Result<Vec<Task>> {
// read from your backend
Ok(vec![])
}
fn save(&self, tasks: &[Task]) -> Result<()> {
// write to your backend
Ok(())
}
fn location(&self) -> String {
"my-backend".to_string()
}
}Re-exports§
pub use json::JsonStorage;pub use memory::InMemoryStorage;pub use json::get_data_file_path;
Modules§
Traits§
- Storage
- Trait defining storage operations for tasks.