pub trait Storage: Send + Sync {
// Required methods
fn get(
&self,
key: &str,
) -> impl Future<Output = Result<Option<Data>>> + Send;
fn set(
&self,
key: &str,
val: Data,
exp: &Duration,
) -> impl Future<Output = Result<()>> + Send;
fn remove(&self, key: &str) -> impl Future<Output = Result<()>> + Send;
// Provided methods
fn reset(&self) -> impl Future<Output = Result<()>> + Send { ... }
fn close(&self) -> impl Future<Output = Result<()>> + Send { ... }
}
Expand description
A Storage Trait
Required Methods§
Sourcefn get(&self, key: &str) -> impl Future<Output = Result<Option<Data>>> + Send
fn get(&self, key: &str) -> impl Future<Output = Result<Option<Data>>> + Send
Gets a Data
from storage by the key
Provided Methods§
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.