Trait Repository

Source
pub trait Repository<V: RepositoryItem>: Send + Sync {
    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 self,
        key: String,
    ) -> Pin<Box<dyn Future<Output = Result<Option<V>, RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<V>, RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set<'life0, 'async_trait>(
        &'life0 self,
        key: String,
        value: V,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove<'life0, 'async_trait>(
        &'life0 self,
        key: String,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

This trait represents a generic repository interface, capable of storing and retrieving items using a key-value API.

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<Option<V>, RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves an item from the repository by its key.

Source

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

Lists all items in the repository.

Source

fn set<'life0, 'async_trait>( &'life0 self, key: String, value: V, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets an item in the repository with the specified key.

Source

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

Removes an item from the repository by its key.

Implementors§