EntityCreator

Trait EntityCreator 

Source
pub trait EntityCreator: Send + Sync {
    // Required method
    fn create_from_json<'life0, 'async_trait>(
        &'life0 self,
        entity_data: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn update_from_json<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _entity_id: &'life1 Uuid,
        _entity_data: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _entity_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for creating entities dynamically

This allows the link system to create new entities with automatic linking without knowing the concrete entity types at compile time.

Required Methods§

Source

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

Create a new entity from JSON data

§Arguments
  • entity_data - The entity data as JSON
§Returns

The created entity serialized as JSON (with generated ID, timestamps, etc.)

Provided Methods§

Source

fn update_from_json<'life0, 'life1, 'async_trait>( &'life0 self, _entity_id: &'life1 Uuid, _entity_data: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update an existing entity from JSON data

§Arguments
  • entity_id - The ID of the entity to update
  • entity_data - The updated entity data as JSON
§Returns

The updated entity serialized as JSON

Default implementation returns an error.

Source

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

Delete an entity by ID

§Arguments
  • entity_id - The ID of the entity to delete
§Returns

Ok(()) if successful, error otherwise

Default implementation returns an error.

Implementors§