LinkService

Trait LinkService 

Source
pub trait LinkService: Send + Sync {
    // Required methods
    fn create<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tenant_id: &'life1 Uuid,
        link_type: &'life2 str,
        source: EntityReference,
        target: EntityReference,
        metadata: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Link>> + 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<Link>>> + 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<Link>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_by_source<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        tenant_id: &'life1 Uuid,
        source_id: &'life2 Uuid,
        source_type: &'life3 str,
        link_type: Option<&'life4 str>,
        target_type: Option<&'life5 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait;
    fn find_by_target<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        tenant_id: &'life1 Uuid,
        target_id: &'life2 Uuid,
        target_type: &'life3 str,
        link_type: Option<&'life4 str>,
        source_type: Option<&'life5 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait;
    fn update<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tenant_id: &'life1 Uuid,
        id: &'life2 Uuid,
        metadata: Option<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Link>> + 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 delete_by_entity<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tenant_id: &'life1 Uuid,
        entity_id: &'life2 Uuid,
        entity_type: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 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 links between entities

This service is completely agnostic to entity types - it only knows about EntityReferences and link types (both Strings).

Required Methods§

Source

fn create<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, link_type: &'life2 str, source: EntityReference, target: EntityReference, metadata: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<Link>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a new link between two entities

Source

fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, id: &'life2 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get a specific link by ID

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all links for a tenant

Source

fn find_by_source<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, source_id: &'life2 Uuid, source_type: &'life3 str, link_type: Option<&'life4 str>, target_type: Option<&'life5 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Find links by source entity

Optionally filter by link_type and/or target_type

Source

fn find_by_target<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, target_id: &'life2 Uuid, target_type: &'life3 str, link_type: Option<&'life4 str>, source_type: Option<&'life5 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Find links by target entity

Optionally filter by link_type and/or source_type

Source

fn update<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, id: &'life2 Uuid, metadata: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<Link>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Update a link’s metadata

This allows updating the metadata associated with a link without recreating it. Useful for adding/modifying contextual information like status, dates, permissions, etc.

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 a link

Source

fn delete_by_entity<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tenant_id: &'life1 Uuid, entity_id: &'life2 Uuid, entity_type: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Delete all links involving a specific entity

Used when deleting an entity to maintain referential integrity

Implementors§