pub trait StateStore: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<StateValue>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
value: StateValue,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<StateKey>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<KeyMetadata>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
meta: KeyMetadata,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Pluggable persistence layer for synced state.
Implementations must be Send + Sync; use Arc<dyn StateStore> for shared access.
§Example
use xenith_core::{InMemoryStore, StateStore, StateKey};
use std::sync::Arc;
let store: Arc<dyn StateStore> = Arc::new(InMemoryStore::default());
let keys = store.list_prefix("uniswap").await.unwrap();Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<StateValue>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<StateValue>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the value for key, or None if it has not been set.
Sourcefn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
value: StateValue,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
value: StateValue,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Insert or overwrite the value for key.
Sourcefn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove the value for key. No-op if the key does not exist.
Sourcefn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<StateKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_prefix<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<StateKey>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return all keys whose string representation starts with prefix.
Sourcefn get_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<KeyMetadata>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<KeyMetadata>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the KeyMetadata for key, or None if not set.
Sourcefn set_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
meta: KeyMetadata,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 StateKey,
meta: KeyMetadata,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store KeyMetadata for key.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".