bookmarks_core/storage.rs
1use anyhow::Result;
2
3use crate::config::Config;
4
5/// Backend-agnostic storage for link data.
6///
7/// Operates on `Config` as a whole — fine-grained CRUD can be added
8/// as default methods later.
9pub trait Storage: Send + Sync {
10 /// Load the full config (urls, groups).
11 fn load(&self) -> Result<Config>;
12
13 /// Save the full config, replacing whatever was stored.
14 fn save(&self, config: &Config) -> Result<()>;
15
16 /// Initialize storage if it doesn't exist yet.
17 fn init(&self) -> Result<()>;
18
19 /// Human-readable backend name ("toml", "database", etc).
20 fn backend_name(&self) -> &str;
21
22 /// Path to the underlying storage (if file-based).
23 fn path(&self) -> Option<&std::path::Path> {
24 None
25 }
26}