StateManager

Trait StateManager 

Source
pub trait StateManager: Send + Sync {
Show 14 methods // Required methods fn save<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, node_id: &'life1 str, state: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn save_with_options<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, node_id: &'life1 str, state: &'life2 T, options: StateOptions, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn load<'life0, 'life1, 'async_trait, T>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>> where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn load_versioned<'life0, 'life1, 'async_trait, T>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<VersionedState<T>>>> + Send + 'async_trait>> where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn exists<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_nodes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn size<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<usize>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, description: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<StateSnapshot>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn restore_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, snapshot_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_snapshots<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<StateSnapshot>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn delete_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, snapshot_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, node_id: &'life1 str, expected: &'life2 T, new: &'life3 T, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where T: 'async_trait + Serialize + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn clear_expired<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Persistent state storage abstraction

Required Methods§

Source

fn save<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, node_id: &'life1 str, state: &'life2 T, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Save state for a node

Source

fn save_with_options<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, node_id: &'life1 str, state: &'life2 T, options: StateOptions, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Save state with options

Source

fn load<'life0, 'life1, 'async_trait, T>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load state for a node

Source

fn load_versioned<'life0, 'life1, 'async_trait, T>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<VersionedState<T>>>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load versioned state with migration support

Source

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

Delete state for a node

Source

fn exists<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if state exists for a node

Source

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

List all node IDs with stored state

Source

fn size<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<usize>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get state size in bytes

Source

fn create_snapshot<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, description: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<StateSnapshot>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a snapshot of current state

Source

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

Restore from a snapshot

Source

fn list_snapshots<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<StateSnapshot>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List snapshots for a node

Source

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

Delete a snapshot

Source

fn compare_and_swap<'life0, 'life1, 'life2, 'life3, 'async_trait, T>( &'life0 self, node_id: &'life1 str, expected: &'life2 T, new: &'life3 T, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + DeserializeOwned + Send + Sync, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Atomic compare-and-swap operation

Source

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

Clear all expired states (based on TTL)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§