GraphBackend

Trait GraphBackend 

Source
pub trait GraphBackend {
Show 14 methods // Required methods fn insert_node(&self, node: NodeSpec) -> Result<i64, SqliteGraphError>; fn get_node(&self, id: i64) -> Result<GraphEntity, SqliteGraphError>; fn insert_edge(&self, edge: EdgeSpec) -> Result<i64, SqliteGraphError>; fn neighbors( &self, node: i64, query: NeighborQuery, ) -> Result<Vec<i64>, SqliteGraphError>; fn bfs(&self, start: i64, depth: u32) -> Result<Vec<i64>, SqliteGraphError>; fn shortest_path( &self, start: i64, end: i64, ) -> Result<Option<Vec<i64>>, SqliteGraphError>; fn node_degree(&self, node: i64) -> Result<(usize, usize), SqliteGraphError>; fn k_hop( &self, start: i64, depth: u32, direction: BackendDirection, ) -> Result<Vec<i64>, SqliteGraphError>; fn k_hop_filtered( &self, start: i64, depth: u32, direction: BackendDirection, allowed_edge_types: &[&str], ) -> Result<Vec<i64>, SqliteGraphError>; fn chain_query( &self, start: i64, chain: &[ChainStep], ) -> Result<Vec<i64>, SqliteGraphError>; fn pattern_search( &self, start: i64, pattern: &PatternQuery, ) -> Result<Vec<PatternMatch>, SqliteGraphError>; fn checkpoint(&self) -> Result<(), SqliteGraphError>; fn snapshot_export( &self, export_dir: &Path, ) -> Result<SnapshotMetadata, SqliteGraphError>; fn snapshot_import( &self, import_dir: &Path, ) -> Result<ImportMetadata, SqliteGraphError>;
}
Expand description

Backend trait defining the interface for graph database backends.

Each trait method delegates to backend-specific primitives while ensuring deterministic behavior and a single integration surface for consumers.

Required Methods§

Source

fn insert_node(&self, node: NodeSpec) -> Result<i64, SqliteGraphError>

Source

fn get_node(&self, id: i64) -> Result<GraphEntity, SqliteGraphError>

Source

fn insert_edge(&self, edge: EdgeSpec) -> Result<i64, SqliteGraphError>

Source

fn neighbors( &self, node: i64, query: NeighborQuery, ) -> Result<Vec<i64>, SqliteGraphError>

Source

fn bfs(&self, start: i64, depth: u32) -> Result<Vec<i64>, SqliteGraphError>

Source

fn shortest_path( &self, start: i64, end: i64, ) -> Result<Option<Vec<i64>>, SqliteGraphError>

Source

fn node_degree(&self, node: i64) -> Result<(usize, usize), SqliteGraphError>

Source

fn k_hop( &self, start: i64, depth: u32, direction: BackendDirection, ) -> Result<Vec<i64>, SqliteGraphError>

Source

fn k_hop_filtered( &self, start: i64, depth: u32, direction: BackendDirection, allowed_edge_types: &[&str], ) -> Result<Vec<i64>, SqliteGraphError>

Source

fn chain_query( &self, start: i64, chain: &[ChainStep], ) -> Result<Vec<i64>, SqliteGraphError>

Source

fn checkpoint(&self) -> Result<(), SqliteGraphError>

Trigger WAL checkpoint for backends that support write-ahead logging

For Native backend with WAL: flushes WAL to graph file For SQLite backend: executes PRAGMA wal_checkpoint(TRUNCATE) For backends without WAL: returns Ok(()) as no-op

Source

fn snapshot_export( &self, export_dir: &Path, ) -> Result<SnapshotMetadata, SqliteGraphError>

Export database snapshot to the specified directory

Creates a consistent snapshot of the current database state. For Native backend: uses V2 snapshot format For SQLite backend: uses JSON dump format

§Arguments
  • export_dir - Directory path where snapshot will be written
§Returns

Snapshot metadata including file paths and size information

Source

fn snapshot_import( &self, import_dir: &Path, ) -> Result<ImportMetadata, SqliteGraphError>

Import database snapshot from the specified directory

Restores database state from a previously created snapshot. For Native backend: loads V2 snapshot format For SQLite backend: loads JSON dump format

§Arguments
  • import_dir - Directory path containing snapshot files
§Returns

Import metadata including number of records imported

Implementations on Foreign Types§

Source§

impl<B> GraphBackend for &B
where B: GraphBackend + ?Sized,

Reference implementation for GraphBackend trait that works with references.

Implementors§