pub trait StorageBackend: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn load_all(&self) -> StorageResult<HashMap<String, StoredEntry>>;
fn save_all(
&self,
entries: &HashMap<String, StoredEntry>,
) -> StorageResult<()>;
fn clear(&self) -> StorageResult<()>;
// Provided method
fn is_available(&self) -> bool { ... }
}Expand description
Trait for pluggable state storage backends.
Implementations must be thread-safe (Send + Sync) to support
concurrent access from the registry.
§Implementation Notes
load_allshould be resilient to partial corruption.save_allshould be atomic (write-then-rename pattern for files).clearshould remove all stored state for the application.
Required Methods§
Sourcefn load_all(&self) -> StorageResult<HashMap<String, StoredEntry>>
fn load_all(&self) -> StorageResult<HashMap<String, StoredEntry>>
Load all stored state entries.
Returns an empty map if no state exists (first run). Skips corrupted entries rather than failing entirely.
Sourcefn save_all(&self, entries: &HashMap<String, StoredEntry>) -> StorageResult<()>
fn save_all(&self, entries: &HashMap<String, StoredEntry>) -> StorageResult<()>
Save all state entries atomically.
This should replace all existing state (not merge).
Sourcefn clear(&self) -> StorageResult<()>
fn clear(&self) -> StorageResult<()>
Clear all stored state.
Provided Methods§
Sourcefn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if the backend is available and functional.