Skip to main content

GraphBackend

Trait GraphBackend 

Source
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§

Source

fn upsert_node(&self, node: &GraphNode) -> Result<()>

Insert or replace a node.

Source

fn read_node(&self, id: &str) -> Result<Option<GraphNode>>

Read a single node by ID (None if absent).

Source

fn delete_node(&self, id: &str) -> Result<bool>

Delete a node by ID. Returns true if a row was removed.

Source

fn search_nodes(&self, query: &str, limit: usize) -> Result<Vec<GraphNode>>

FTS5 full-text search, ranked by importance DESC.

Source

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.

Source

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”.

Source

fn related_nodes(&self, start_id: &str, depth: usize) -> Result<Vec<String>>

BFS-traverse up to depth hops from start_id, returning related node IDs (excluding the start).

Source

fn append_edge(&self, edge: &GraphEdge) -> Result<()>

Append an edge (duplicates by edge ID are ignored).

Source

fn edges_for_node(&self, node_id: &str) -> Result<Vec<GraphEdge>>

Read edges where the given node is source or target.

Source

fn delete_edge(&self, id: &str) -> Result<bool>

Delete an edge by ID. Returns true if a row was removed.

Source

fn remove_edges_for_node(&self, node_id: &str) -> Result<()>

Remove every edge connected to a node.

Source

fn current_version(&self) -> Result<u32>

Recorded schema version for this backend.

Source

fn migrate(&self) -> Result<u32>

Apply pending migrations up to the backend’s latest schema version. Returns the resulting version.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§