Skip to main content

StoreBackend

Trait StoreBackend 

Source
pub trait StoreBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load(&self, store_id: &str, device_id: &str) -> Option<(Vec<u8>, u64)>;
    fn save(&self, store_id: &str, device_id: &str, data: &[u8], version: u64);
    fn remove(&self, store_id: &str, device_id: &str);
}
Expand description

Backend for persisting store data across restarts.

Methods are synchronous — file I/O for small JSON payloads is fast enough that async overhead isn’t warranted. Apps needing async persistence (e.g., database-backed) can spawn a blocking task internally.

Required Methods§

Source

fn load(&self, store_id: &str, device_id: &str) -> Option<(Vec<u8>, u64)>

Load a device’s slice. Returns (serialized_data, version) or None.

Source

fn save(&self, store_id: &str, device_id: &str, data: &[u8], version: u64)

Save a device’s slice.

Source

fn remove(&self, store_id: &str, device_id: &str)

Remove a device’s slice.

Implementors§