pub trait Repository<T: AggregateRoot>: ReadRepository<T> {
    fn add<'life0, 'async_trait>(
        &'life0 self,
        entity: T
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn update<'life0, 'async_trait>(
        &'life0 self,
        entity: T
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn delete<'life0, 'async_trait>(
        &'life0 self,
        entity: T
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn add_range<'life0, 'async_trait>(
        &'life0 self,
        entities: Vec<T>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
    where
        Self: Sync + 'async_trait,
        'life0: 'async_trait
, { ... } fn update_range<'life0, 'async_trait>(
        &'life0 self,
        entities: Vec<T>
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
    where
        Self: Sync + 'async_trait,
        'life0: 'async_trait
, { ... } fn delete_range<'life0, 'async_trait>(
        &'life0 self,
        entities: Vec<T>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        Self: Sync + 'async_trait,
        'life0: 'async_trait
, { ... } }
Expand description

Trait for representing a Repository.

Therefore, use a Repository, the purpose of which is to encapsulate all the logic needed to obtain object references. The domain objects won’t have to deal with the infrastructure to get the needed references to other objects of the domain. They will just get them from the Repository and the model is regaining its clarity and focus.

Examples

See InMemoryRepository for a sample implementation of this trait.

Required Methods§

source

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

Adds an entity to the repository.

source

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

Updates an entity on the repository.

source

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

Deletes the entity from the repository.

Provided Methods§

source

fn add_range<'life0, 'async_trait>(
    &'life0 self,
    entities: Vec<T>
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
    Self: Sync + 'async_trait,
    'life0: 'async_trait,

Adds the given entities to the repository.

source

fn update_range<'life0, 'async_trait>(
    &'life0 self,
    entities: Vec<T>
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
    Self: Sync + 'async_trait,
    'life0: 'async_trait,

Updates the given entities on the repository.

source

fn delete_range<'life0, 'async_trait>(
    &'life0 self,
    entities: Vec<T>
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
    Self: Sync + 'async_trait,
    'life0: 'async_trait,

Deletes the given entities from the repository.

Implementors§

source§

impl<T: AggregateRoot + Clone> Repository<T> for InMemoryRepository<T>where
    <T as Entity>::Id: Hash + Eq,

source§

impl<T: AggregateRoot, TRepository: Repository<T>, TDomainEventHandler: DomainEventHandler<<T as AggregateRoot>::DomainEvent>> Repository<T> for DomainRepository<T, TRepository, TDomainEventHandler>