Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore: Send + Sync {
    // Required methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        query: GraphQuery,
    ) -> Pin<Box<dyn Future<Output = Result<JsonValue, GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn upsert_node<'life0, 'async_trait>(
        &'life0 self,
        node: GraphNode,
    ) -> Pin<Box<dyn Future<Output = Result<(), GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn upsert_edge<'life0, 'async_trait>(
        &'life0 self,
        edge: GraphEdge,
    ) -> Pin<Box<dyn Future<Output = Result<(), GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_node<'life0, 'life1, 'async_trait>(
        &'life0 self,
        node_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<GraphNode>, GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn neighbors<'life0, 'life1, 'async_trait>(
        &'life0 self,
        node_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNode>, GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn traverse<'life0, 'life1, 'async_trait>(
        &'life0 self,
        start: &'life1 str,
        max_depth: usize,
    ) -> Pin<Box<dyn Future<Output = Result<GraphSubgraph, GraphDbError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Adapter trait for graph database backends.

Implement this trait to support a new graph backend (Neo4j, Surreal, in-memory).

Required Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 self, query: GraphQuery, ) -> Pin<Box<dyn Future<Output = Result<JsonValue, GraphDbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a query and return JSON results.

Source

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

Upsert a node into the store.

Source

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

Upsert an edge into the store.

Source

fn get_node<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<GraphNode>, GraphDbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a node by id.

Source

fn neighbors<'life0, 'life1, 'async_trait>( &'life0 self, node_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNode>, GraphDbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return immediate neighbor nodes for node_id.

Source

fn traverse<'life0, 'life1, 'async_trait>( &'life0 self, start: &'life1 str, max_depth: usize, ) -> Pin<Box<dyn Future<Output = Result<GraphSubgraph, GraphDbError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Traverse from start and return a GraphSubgraph up to max_depth.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§