Trait ReadRepository

Source
pub trait ReadRepository<T: AggregateRoot>: Send + Sync {
    // Required methods
    fn get_by_id<'life0, 'async_trait>(
        &'life0 self,
        id: <T as Entity>::Id,
    ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
        skip: usize,
        take: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn exists<'life0, 'async_trait>(
        &'life0 self,
        id: <T as Entity>::Id,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn is_empty<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for representing a read-only Repository.

See the Repository trait for the definition of a repository and a sample of its usage.

Required Methods§

Source

fn get_by_id<'life0, 'async_trait>( &'life0 self, id: <T as Entity>::Id, ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets an entity with the given ID.

Source

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

Lists all entities within a given page.

Source

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

Returns the total number of entities in the repository.

Provided Methods§

Source

fn exists<'life0, 'async_trait>( &'life0 self, id: <T as Entity>::Id, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks whether an entity with the given ID exists in the repository.

Source

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

Checks if the repository is empty.

Implementors§