Skip to main content

StateStore

Trait StateStore 

Source
pub trait StateStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn save_state<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        node_id: NodeId,
        state: &'life1 T,
    ) -> Pin<Box<dyn Future<Output = Result<(), FloxideError>> + Send + 'async_trait>>
       where T: 'async_trait + Serialize + Send + Sync + 'static,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_state<'life0, 'async_trait, T>(
        &'life0 self,
        node_id: NodeId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<T>, FloxideError>> + Send + 'async_trait>>
       where T: 'async_trait + for<'de> Deserialize<'de> + Send + Sync + 'static,
             Self: 'async_trait,
             'life0: 'async_trait;
    fn has_state<'life0, 'async_trait>(
        &'life0 self,
        node_id: NodeId,
    ) -> Pin<Box<dyn Future<Output = Result<bool, FloxideError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_state<'life0, 'async_trait>(
        &'life0 self,
        node_id: NodeId,
    ) -> Pin<Box<dyn Future<Output = Result<(), FloxideError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_all_node_ids<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>, FloxideError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for storing and retrieving node states.

Required Methods§

Source

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

Save a node’s state

Source

fn get_state<'life0, 'async_trait, T>( &'life0 self, node_id: NodeId, ) -> Pin<Box<dyn Future<Output = Result<Option<T>, FloxideError>> + Send + 'async_trait>>
where T: 'async_trait + for<'de> Deserialize<'de> + Send + Sync + 'static, Self: 'async_trait, 'life0: 'async_trait,

Get a node’s state if it exists

Source

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

Check if a node has saved state

Source

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

Remove a node’s state

Source

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

Get all node IDs with saved states

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§