pub trait Repository: Send + Sync {
type Entity: Send + Sync + Debug;
type Id: Send + Sync + Debug + Clone;
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'async_trait>(
&'life0 self,
pagination: Option<PaginationParams>,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Vec<Self::Entity>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: &'life1 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
entity: &'life2 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn count<'life0, 'async_trait>(
&'life0 self,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Base repository trait
This trait defines common operations that all repositories should support.
Required Associated Types§
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get an entity by ID
Sourcefn list<'life0, 'async_trait>(
&'life0 self,
pagination: Option<PaginationParams>,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Vec<Self::Entity>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list<'life0, 'async_trait>(
&'life0 self,
pagination: Option<PaginationParams>,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Vec<Self::Entity>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List entities with optional pagination and filters
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: &'life1 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: &'life1 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new entity
Sourcefn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
entity: &'life2 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
entity: &'life2 Self::Entity,
) -> Pin<Box<dyn Future<Output = RepositoryResult<Self::Entity>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update an existing entity
Provided Methods§
Sourcefn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Self::Id,
) -> Pin<Box<dyn Future<Output = RepositoryResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if an entity exists
Sourcefn count<'life0, 'async_trait>(
&'life0 self,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn count<'life0, 'async_trait>(
&'life0 self,
filters: Option<FilterParams>,
) -> Pin<Box<dyn Future<Output = RepositoryResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Count entities matching filters