pub trait GraphBackend: Send + Sync {
Show 13 methods
// Required methods
fn upsert_node(&self, node: &GraphNode) -> Result<()>;
fn read_node(&self, id: &str) -> Result<Option<GraphNode>>;
fn delete_node(&self, id: &str) -> Result<bool>;
fn search_nodes(&self, query: &str, limit: usize) -> Result<Vec<GraphNode>>;
fn query_nodes(
&self,
tag: Option<&str>,
node_type: Option<&str>,
project: Option<&str>,
limit: usize,
) -> Result<Vec<GraphNode>>;
fn smart_recall(
&self,
project: Option<&str>,
hint: Option<&str>,
limit: usize,
) -> Result<Vec<ScoredNode>>;
fn related_nodes(&self, start_id: &str, depth: usize) -> Result<Vec<String>>;
fn append_edge(&self, edge: &GraphEdge) -> Result<()>;
fn edges_for_node(&self, node_id: &str) -> Result<Vec<GraphEdge>>;
fn delete_edge(&self, id: &str) -> Result<bool>;
fn remove_edges_for_node(&self, node_id: &str) -> Result<()>;
fn current_version(&self) -> Result<u32>;
fn migrate(&self) -> Result<u32>;
}Expand description
Sync, object-safe trait for graph backends.
Methods cover node/edge CRUD, FTS search, filtered query, and schema
migration. No method exposes rusqlite types, so the trait is implementable
by any backend. dyn GraphBackend is usable.
Required Methods§
Sourcefn upsert_node(&self, node: &GraphNode) -> Result<()>
fn upsert_node(&self, node: &GraphNode) -> Result<()>
Insert or replace a node.
Sourcefn read_node(&self, id: &str) -> Result<Option<GraphNode>>
fn read_node(&self, id: &str) -> Result<Option<GraphNode>>
Read a single node by ID (None if absent).
Sourcefn delete_node(&self, id: &str) -> Result<bool>
fn delete_node(&self, id: &str) -> Result<bool>
Delete a node by ID. Returns true if a row was removed.
Sourcefn search_nodes(&self, query: &str, limit: usize) -> Result<Vec<GraphNode>>
fn search_nodes(&self, query: &str, limit: usize) -> Result<Vec<GraphNode>>
FTS5 full-text search, ranked by importance DESC.
Sourcefn query_nodes(
&self,
tag: Option<&str>,
node_type: Option<&str>,
project: Option<&str>,
limit: usize,
) -> Result<Vec<GraphNode>>
fn query_nodes( &self, tag: Option<&str>, node_type: Option<&str>, project: Option<&str>, limit: usize, ) -> Result<Vec<GraphNode>>
Dynamic filter by tag / node_type / project.
Sourcefn smart_recall(
&self,
project: Option<&str>,
hint: Option<&str>,
limit: usize,
) -> Result<Vec<ScoredNode>>
fn smart_recall( &self, project: Option<&str>, hint: Option<&str>, limit: usize, ) -> Result<Vec<ScoredNode>>
Composite recall — rank nodes by recency, importance, access, FTS, and graph boost. The canonical high-level read path for “what’s relevant”.
BFS-traverse up to depth hops from start_id, returning related node
IDs (excluding the start).
Sourcefn append_edge(&self, edge: &GraphEdge) -> Result<()>
fn append_edge(&self, edge: &GraphEdge) -> Result<()>
Append an edge (duplicates by edge ID are ignored).
Sourcefn edges_for_node(&self, node_id: &str) -> Result<Vec<GraphEdge>>
fn edges_for_node(&self, node_id: &str) -> Result<Vec<GraphEdge>>
Read edges where the given node is source or target.
Sourcefn delete_edge(&self, id: &str) -> Result<bool>
fn delete_edge(&self, id: &str) -> Result<bool>
Delete an edge by ID. Returns true if a row was removed.
Sourcefn remove_edges_for_node(&self, node_id: &str) -> Result<()>
fn remove_edges_for_node(&self, node_id: &str) -> Result<()>
Remove every edge connected to a node.
Sourcefn current_version(&self) -> Result<u32>
fn current_version(&self) -> Result<u32>
Recorded schema version for this backend.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".