Skip to main content

KnowledgeGraph

Trait KnowledgeGraph 

Source
pub trait KnowledgeGraph: Send + Sync {
    // Required methods
    fn add_triple<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
        subject: EntityId,
        predicate: &'life2 str,
        object: EntityId,
        valid_from: Option<&'life3 str>,
        confidence: f32,
        source_memory_id: Option<&'life4 str>,
    ) -> Pin<Box<dyn Future<Output = Result<Triple>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn query_entity<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
        entity: &'life2 EntityId,
    ) -> Pin<Box<dyn Future<Output = Result<EntityRecord>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn invalidate_triple<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
        triple_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn find_triples<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
        subject: Option<&'life2 EntityId>,
        predicate: Option<&'life3 str>,
        object: Option<&'life4 EntityId>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn kg_timeline<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn knowledge_stats<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ns: &'life1 NamespaceId,
    ) -> Pin<Box<dyn Future<Output = Result<KgStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn kg_global_stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<KgStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The knowledge-graph contract every backend implements alongside crate::Store. All methods are scoped to a NamespaceId.

Required Methods§

Source

fn add_triple<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, subject: EntityId, predicate: &'life2 str, object: EntityId, valid_from: Option<&'life3 str>, confidence: f32, source_memory_id: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<Triple>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Adds (or refreshes) the subject + object entities and creates a triple edge between them. Returns the created Triple.

Source

fn query_entity<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, entity: &'life2 EntityId, ) -> Pin<Box<dyn Future<Output = Result<EntityRecord>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Returns an entity and all its connected triples (outgoing + incoming) within ns.

Source

fn invalidate_triple<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, triple_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Marks a triple as no longer current by setting valid_to. Idempotent.

Source

fn find_triples<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, subject: Option<&'life2 EntityId>, predicate: Option<&'life3 str>, object: Option<&'life4 EntityId>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Finds triples matching any combination of subject / predicate / object (None = wildcard).

Source

fn kg_timeline<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns triples in chronological order (by valid_from), most recent first.

Source

fn knowledge_stats<'life0, 'life1, 'async_trait>( &'life0 self, ns: &'life1 NamespaceId, ) -> Pin<Box<dyn Future<Output = Result<KgStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Entity + triple counts for ns.

Source

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

Global entity + triple counts across all namespaces.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§