DataSource

Trait DataSource 

Source
pub trait DataSource: Send + Sync {
    // Required methods
    fn read_entity<'life0, 'life1, 'life2, 'async_trait, T>(
        &'life0 self,
        entity_type: &'life1 str,
        entity_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
       where T: 'async_trait + RagEntity + CandidType,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn read_entities<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        entity_type: &'life1 str,
        entity_ids: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where T: 'async_trait + RagEntity + CandidType + Send,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn query_entities<'life0, 'life1, 'async_trait, T>(
        &'life0 self,
        entity_type: &'life1 str,
        filter: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where T: 'async_trait + RagEntity + CandidType,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for data sources that can provide entities

Implement this trait to create custom data sources for your canister.

Required Methods§

Source

fn read_entity<'life0, 'life1, 'life2, 'async_trait, T>( &'life0 self, entity_type: &'life1 str, entity_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + RagEntity + CandidType, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Read a single entity by ID

Source

fn read_entities<'life0, 'life1, 'async_trait, T>( &'life0 self, entity_type: &'life1 str, entity_ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + RagEntity + CandidType + Send, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read multiple entities by IDs

Provided Methods§

Source

fn query_entities<'life0, 'life1, 'async_trait, T>( &'life0 self, entity_type: &'life1 str, filter: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'async_trait + RagEntity + CandidType, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query entities with optional filtering This is optional and can be implemented for more advanced querying

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§