Trait noosphere_storage::KeyValueStore
source · pub trait KeyValueStore: Clone + KeyValueSendSync {
fn set_key<'life0, 'async_trait, K, V>(
&'life0 mut self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: Serialize + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn get_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>
where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn unset_key<'life0, 'async_trait, K>(
&'life0 mut self,
key: K
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn require_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>>
where
K: AsRef<[u8]> + KeyValueStoreSend + Display + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
{ ... }
}Expand description
A KeyValueStore is a construct that is suitable for persisting generic key/value data to a storage backend.
Required Methods§
sourcefn set_key<'life0, 'async_trait, K, V>(
&'life0 mut self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: Serialize + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn set_key<'life0, 'async_trait, K, V>(
&'life0 mut self,
key: K,
value: V
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: Serialize + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Given some key that can be realized as bytes, persist a serializable value to storage so that it can later be retrieved by that key
sourcefn get_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn get_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<Option<V>>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Given some key that can be realized as bytes, retrieve some data that can be deserialized as the intended data structure
sourcefn unset_key<'life0, 'async_trait, K>(
&'life0 mut self,
key: K
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn unset_key<'life0, 'async_trait, K>(
&'life0 mut self,
key: K
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Given some key that can be realized as bytes, unset the value stored against that key (if any)
Provided Methods§
sourcefn require_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + Display + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn require_key<'life0, 'async_trait, K, V>(
&'life0 self,
key: K
) -> Pin<Box<dyn Future<Output = Result<V>> + Send + 'async_trait>>where
K: AsRef<[u8]> + KeyValueStoreSend + Display + 'async_trait,
V: DeserializeOwned + KeyValueStoreSend + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
Same as get_key, but returns an error if no value is found to be stored against the key