Trait ddd_rs::application::Repository
source · pub trait Repository<T: AggregateRoot>: ReadRepository<T> {
// Required methods
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;
// Provided methods
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.
Example
See InMemoryRepository for a sample implementation of this trait.
Required Methods§
sourcefn 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 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.
Provided Methods§
sourcefn 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 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.