Skip to main content

AsyncStorage

Trait AsyncStorage 

Source
pub trait AsyncStorage: Send + Sync {
    type Entity: Send + Sync;
    type Document: Send + Sync;
    type Chunk: Send + Sync;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn store_entity<'life0, 'async_trait>(
        &'life0 mut self,
        entity: Self::Entity,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retrieve_entity<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Entity>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn store_document<'life0, 'async_trait>(
        &'life0 mut self,
        document: Self::Document,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retrieve_document<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Document>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn store_chunk<'life0, 'async_trait>(
        &'life0 mut self,
        chunk: Self::Chunk,
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retrieve_chunk<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Chunk>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_entities<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn store_entities_batch<'life0, 'async_trait>(
        &'life0 mut self,
        entities: Vec<Self::Entity>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn flush<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Async storage abstraction for non-blocking storage operations

§Async Version

This trait provides async operations for storage with better concurrency and resource utilization.

Required Associated Types§

Source

type Entity: Send + Sync

The entity type this storage handles

Source

type Document: Send + Sync

The document type this storage handles

Source

type Chunk: Send + Sync

The chunk type this storage handles

Source

type Error: Error + Send + Sync + 'static

The error type returned by storage operations

Required Methods§

Source

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

Store an entity and return its assigned ID

Source

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

Retrieve an entity by its ID

Source

fn store_document<'life0, 'async_trait>( &'life0 mut self, document: Self::Document, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a document and return its assigned ID

Source

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

Retrieve a document by its ID

Source

fn store_chunk<'life0, 'async_trait>( &'life0 mut self, chunk: Self::Chunk, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a chunk and return its assigned ID

Source

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

Retrieve a chunk by its ID

Source

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

List all entity IDs

Source

fn store_entities_batch<'life0, 'async_trait>( &'life0 mut self, entities: Vec<Self::Entity>, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Batch operations for performance

Provided Methods§

Source

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

Health check for storage connection

Source

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

Flush any pending operations

Implementors§

Source§

impl<T> AsyncStorage for StorageAdapter<T>
where T: Storage + Send + Sync + 'static, T::Entity: Send + Sync, T::Document: Send + Sync, T::Chunk: Send + Sync,