WriteRepo

Trait WriteRepo 

Source
pub trait WriteRepo: Sync {
    type Entity: MutableEntity + Send + Sync;

    // Required methods
    fn add<'life0, 'async_trait>(
        &'life0 self,
        item: Self::Entity,
    ) -> Pin<Box<dyn Future<Output = RepoResult<Self::Entity>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'async_trait>(
        &'life0 self,
        item: Self::Entity,
    ) -> Pin<Box<dyn Future<Output = RepoResult<Self::Entity>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 <Self::Entity as Entity>::Key,
    ) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait to add mutability operations to repositories.

Unlike Repo trait, implementations of this trait can have side effects on the stored data, thus extra care needs to be taken when used.

Required Associated Types§

Source

type Entity: MutableEntity + Send + Sync

The type of the entity that this repository operates on.

Required Methods§

Source

fn add<'life0, 'async_trait>( &'life0 self, item: Self::Entity, ) -> Pin<Box<dyn Future<Output = RepoResult<Self::Entity>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adds an item to the data repository.

§Arguments
  • item - Item to be added
Source

fn update<'life0, 'async_trait>( &'life0 self, item: Self::Entity, ) -> Pin<Box<dyn Future<Output = RepoResult<Self::Entity>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates an item in the data repository.

The item must be present in the data repository, as implementations of this trait shall not create the item if it does not exist.

§Arguments
  • item - Item to be updated
Source

fn remove<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 <Self::Entity as Entity>::Key, ) -> Pin<Box<dyn Future<Output = RepoResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes an item from the data repository.

§Arguments
  • key - The key of the item to be removed

Implementors§