Skip to main content

GraphStore

Trait GraphStore 

Source
pub trait GraphStore: Send + Sync {
    // Required methods
    fn put_node<'life0, 'life1, 'async_trait>(
        &'life0 self,
        node: &'life1 Node,
    ) -> Pin<Box<dyn Future<Output = Result<PutOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put_edge<'life0, 'life1, 'async_trait>(
        &'life0 self,
        edge: &'life1 Edge,
    ) -> Pin<Box<dyn Future<Output = Result<PutOutcome>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_node<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 NodeId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Node>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_edges<'life0, 'async_trait>(
        &'life0 self,
        query: EdgeQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Edge>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn traverse<'life0, 'async_trait>(
        &'life0 self,
        traversal: Traversal,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Node>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn apply_schema<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _schema: &'life1 GraphSchema,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn constraint_capability(
        &self,
        _constraint: &GraphConstraint,
    ) -> GraphConstraintCapability { ... }
    fn native_constraint_capability(
        &self,
        _constraint: &GraphConstraint,
    ) -> GraphNativeConstraintCapability { ... }
    fn apply_native_constraint<'life0, 'async_trait>(
        &'life0 self,
        request: GraphNativeConstraintRequest,
    ) -> Pin<Box<dyn Future<Output = Result<GraphNativeConstraintReport>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn put_graph<'life0, 'life1, 'async_trait>(
        &'life0 self,
        graph: &'life1 Graph,
    ) -> Pin<Box<dyn Future<Output = Result<LoadReport>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn put_typed_graph<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        schema: &'life1 GraphSchema,
        graph: &'life2 Graph,
    ) -> Pin<Box<dyn Future<Output = Result<LoadReport>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn get_nodes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ids: &'life1 [NodeId],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Node>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Required Methods§

Source

fn put_node<'life0, 'life1, 'async_trait>( &'life0 self, node: &'life1 Node, ) -> Pin<Box<dyn Future<Output = Result<PutOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Writes one node.

The returned PutOutcome reports the most precise result the backend can provide. Remote upsert backends generally return PutOutcome::Upserted for both inserts and updates.

Source

fn put_edge<'life0, 'life1, 'async_trait>( &'life0 self, edge: &'life1 Edge, ) -> Pin<Box<dyn Future<Output = Result<PutOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Writes one edge.

The returned PutOutcome reports the most precise result the backend can provide. Remote upsert backends generally return PutOutcome::Upserted for both inserts and updates.

Source

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

Source

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

Source

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

Provided Methods§

Source

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

Applies backend schema metadata.

GraphSchema is a portable declaration of expected node labels, edge labels, fields, endpoint labels, direction, and uniqueness. The default implementation is a no-op for schemaless stores. Backend implementations may use the schema for validation, typed native tables, views, indexes, generated query shapes, or database-native schema definitions.

Applying a schema does not imply the same enforcement guarantee on every backend. Callers that need portable preflight validation should call GraphSchema::validate_graph before writing, or use GraphStore::put_typed_graph, which does that validation before applying the backend schema and writing the graph. Individual backends document whether they also validate each subsequent write at runtime.

Source

fn constraint_capability( &self, _constraint: &GraphConstraint, ) -> GraphConstraintCapability

Reports how this backend treats a portable graph constraint.

The default is metadata-only: the backend may remember or lower the constraint as schema metadata, but callers should not assume runtime enforcement. Backends that validate through GraphSchema before each write can report GraphConstraintCapability::ValidateBeforeWrite. Backends with database-native guarantees can report GraphConstraintCapability::EnforcedByBackend.

Source

fn native_constraint_capability( &self, _constraint: &GraphConstraint, ) -> GraphNativeConstraintCapability

Reports whether this backend can turn a portable graph constraint into backend-native DDL.

This is an explicit opt-in surface. GraphStore::apply_schema remains the portable schema/validation hook and must not be assumed to create backend-native constraints. The default implementation reports no native support.

Source

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

Applies one backend-native constraint or index request.

Backends should implement this only when they can describe the native object they create and its enforcement behavior through GraphNativeConstraintCapability. The default returns an explicit unsupported error so callers cannot mistake metadata-only schema application for native DDL.

Source

fn put_graph<'life0, 'life1, 'async_trait>( &'life0 self, graph: &'life1 Graph, ) -> Pin<Box<dyn Future<Output = Result<LoadReport>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn put_typed_graph<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, schema: &'life1 GraphSchema, graph: &'life2 Graph, ) -> Pin<Box<dyn Future<Output = Result<LoadReport>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn get_nodes<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [NodeId], ) -> Pin<Box<dyn Future<Output = Result<Vec<Node>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads multiple nodes by ID.

The default implementation preserves the input order and calls GraphStore::get_node once per ID. Backends with a native batch-read path should override this to avoid per-node round trips during traversal and other fan-out reads.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§