DataService

Trait DataService 

Source
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§

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Implementors§