Skip to main content

Storage

Trait Storage 

Source
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§

Source

fn get(&self, key: &str) -> impl Future<Output = Result<Option<Data>>> + Send

Gets a Data from storage by the key

Source

fn set( &self, key: &str, val: Data, exp: &Duration, ) -> impl Future<Output = Result<()>> + Send

Sets a session Data into storage

Source

fn remove(&self, key: &str) -> impl Future<Output = Result<()>> + Send

Removes a data from storage by the key

Provided Methods§

Source

fn reset(&self) -> impl Future<Output = Result<()>> + Send

Resets the storage and remove all keys

Source

fn close(&self) -> impl Future<Output = Result<()>> + Send

Closes the connection

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§