pub trait KeyValueStore: Clone + ConditionalSync {
// Required methods
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]> + ConditionalSend + 'async_trait,
V: Serialize + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
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]> + ConditionalSend + Display + 'async_trait,
V: DeserializeOwned + ConditionalSend + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
fn flush<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where 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]> + ConditionalSend + 'async_trait,
V: Serialize + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
V: Serialize + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + 'async_trait,
V: DeserializeOwned + ConditionalSend + '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
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]> + ConditionalSend + Display + 'async_trait,
V: DeserializeOwned + ConditionalSend + '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]> + ConditionalSend + Display + 'async_trait,
V: DeserializeOwned + ConditionalSend + '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
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.