Trait keyv::Store

source ·
pub trait Store: Send + Sync {
    // Required methods
    fn initialize<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Value,
        ttl: Option<u64>
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn remove_many<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        keys: &'life1 [&'life2 str]
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}

Required Methods§

source

fn initialize<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initializes the storage backend. This method should perform any necessary setup for the storage backend, such as establishing database connections or ensuring the existence of required files or schemas.

§Returns
  • Ok(()) on success.
  • Err(StoreError) if initialisation fails.
source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a value associated with a given key from the store.

§Arguments
  • key: A string slice that holds the key for the value to be retrieved.
§Returns
  • Ok(Some(Value)) if the key exists and the value is successfully retrieved.
  • Ok(None) if the key does not exist.
  • Err(StoreError) if there is an error retrieving the value.
source

fn set<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: Value, ttl: Option<u64> ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sets a value for a given key in the store, with an optional time-to-live (TTL).

§Arguments
  • key: The key under which the value is stored.
  • value: The value to set, represented as a serde_json::Value.
  • ttl: An optional u64 representing the time-to-live in seconds.
§Returns
  • Ok(()) if the value is successfully set.
  • Err(StoreError) if there is an error setting the value.
source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes a value associated with a given key from the store.

§Arguments
  • key: A string slice that holds the key for the value to be removed.
§Returns
  • Ok(()) if the key exists and the value is successfully removed.
  • Err(StoreError) if there is an error removing the value.
source

fn remove_many<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, keys: &'life1 [&'life2 str] ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Removes multiple values associated with the given keys from the store.

§Arguments
  • keys: A slice of string slices representing the keys for the values to be removed.
§Returns
  • Ok(()) if the values are successfully removed.
  • Err(StoreError) if there is an error removing the values.
source

fn clear<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clears all values from the store.

§Returns
  • Ok(()) if the store is successfully cleared.
  • Err(StoreError) if there is an error clearing the store.

Implementors§