Skip to main content

Repository

Trait Repository 

Source
pub trait Repository<V: RepositoryItem>: Send + Sync {
    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 self,
        key: V::Key,
    ) -> 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: V::Key,
        value: V,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn set_bulk<'life0, 'async_trait>(
        &'life0 self,
        values: Vec<(V::Key, 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: V::Key,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_bulk<'life0, 'async_trait>(
        &'life0 self,
        keys: Vec<V::Key>,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn replace_all<'life0, 'async_trait>(
        &'life0 self,
        values: Vec<(V::Key, V)>,
    ) -> 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: V::Key, ) -> 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: V::Key, 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 set_bulk<'life0, 'async_trait>( &'life0 self, values: Vec<(V::Key, V)>, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets multiple items in the repository.

Source

fn remove<'life0, 'async_trait>( &'life0 self, key: V::Key, ) -> 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.

Source

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

Removes multiple items from the repository by their keys.

Source

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

Removes all items from the repository.

Provided Methods§

Source

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

Replaces all items in the repository with the provided values. This is a convenience method that first removes all existing items and then sets the new items in bulk.

In the future we may want to explore using revision dates to optimize this operation.

Implementors§