StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
    // Required methods
    fn store_entity<'life0, 'life1, 'async_trait>(
        &'life0 self,
        entity: &'life1 Entity,
    ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_entity<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Entity>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_entity<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Entity>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_entities<'life0, 'async_trait>(
        &'life0 self,
        entity_type: Option<EntityType>,
        limit: usize,
        offset: usize,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Entity>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count_entities<'life0, 'async_trait>(
        &'life0 self,
        entity_type: Option<EntityType>,
    ) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Abstract storage backend for entities.

TigerStyle: All operations are async, return explicit errors.

Required Methods§

Source

fn store_entity<'life0, 'life1, 'async_trait>( &'life0 self, entity: &'life1 Entity, ) -> Pin<Box<dyn Future<Output = StorageResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store or update an entity.

If entity with same ID exists, it is updated. Returns the entity ID.

Source

fn get_entity<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an entity by ID.

Returns None if entity does not exist.

Source

fn delete_entity<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an entity by ID.

Returns true if entity existed and was deleted.

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search entities by text query.

Simple text matching for SimStorageBackend. Vector/semantic search for PostgresBackend.

Source

fn list_entities<'life0, 'async_trait>( &'life0 self, entity_type: Option<EntityType>, limit: usize, offset: usize, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Entity>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List entities with optional type filter.

Source

fn count_entities<'life0, 'async_trait>( &'life0 self, entity_type: Option<EntityType>, ) -> Pin<Box<dyn Future<Output = StorageResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Count entities with optional type filter.

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all entities.

Primarily for testing.

Implementors§