pub trait DataService<T: Data>: Send + Sync {
// Required methods
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
field: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
}Expand description
Service trait for managing data entities
Implementations provide CRUD operations for a specific entity type. The framework is agnostic to the underlying storage mechanism.
Required Methods§
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new entity
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get an entity by ID
Sourcefn list<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List all entities for a tenant
Sourcefn update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + 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,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
entity: T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update an existing entity
Sourcefn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete an entity
Sourcefn search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
field: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn search<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tenant_id: &'life1 Uuid,
field: &'life2 str,
value: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Search entities by field values