Skip to main content

Snapshotable

Trait Snapshotable 

Source
pub trait Snapshotable: Send + Sync {
    type Key: Clone + Eq + Hash + Send + Sync;
    type State: Clone + Send + Sync;

    // Required methods
    fn list_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<HashMap<Self::Key, Self::State>, SnapshotError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn restore<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 Self::Key,
        state: Self::State,
    ) -> Pin<Box<dyn Future<Output = Result<(), SnapshotError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SnapshotError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for services that can be snapshotted.

Implement this for any service whose state needs to be persisted and restored atomically with stream offsets.

Required Associated Types§

Source

type Key: Clone + Eq + Hash + Send + Sync

The key type for identifying entities (e.g., WalletAddress)

Source

type State: Clone + Send + Sync

The state type for each keyed entity (e.g., wallet -> balance)

Required Methods§

Source

fn list_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<Self::Key, Self::State>, SnapshotError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all states keyed by identifier.

Source

fn restore<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 Self::Key, state: Self::State, ) -> Pin<Box<dyn Future<Output = Result<(), SnapshotError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Restore a single state entry.

Source

fn clear_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), SnapshotError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all state before restore.

Implementors§