pub trait GraphStore: Send + Sync {
Show 13 methods
// Required methods
fn add_node<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
id: &'life1 str,
memory: &'life2 str,
metadata: &'life3 HashMap<String, Value>,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait;
fn add_nodes_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
nodes: &'life1 [MemoryNode],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn add_edges_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
edges: &'life1 [MemoryEdge],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn get_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn get_neighbors<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
relation: Option<&'life2 str>,
direction: GraphDirection,
limit: usize,
include_embedding: bool,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNeighbor>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn shortest_path<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<GraphPath>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait;
fn find_paths<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
top_k: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphPath>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait;
fn search_by_embedding<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
top_k: usize,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VecSearchHit>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn get_all_memory_items<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
user_name: &'life2 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn update_node<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
fields: &'life2 HashMap<String, Value>,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait;
fn delete_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
fn delete_edges_by_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<usize, GraphStoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait;
}Expand description
Graph store abstraction (subset of MemOS BaseGraphDB).
Required Methods§
Sourcefn add_node<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
id: &'life1 str,
memory: &'life2 str,
metadata: &'life3 HashMap<String, Value>,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn add_node<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
id: &'life1 str,
memory: &'life2 str,
metadata: &'life3 HashMap<String, Value>,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Add a single memory node.
Sourcefn add_nodes_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
nodes: &'life1 [MemoryNode],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn add_nodes_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
nodes: &'life1 [MemoryNode],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Add multiple nodes in batch.
Sourcefn add_edges_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
edges: &'life1 [MemoryEdge],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn add_edges_batch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
edges: &'life1 [MemoryEdge],
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Add multiple edges in batch.
Sourcefn get_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_node<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Get one node by id.
Sourcefn get_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn get_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
ids: &'life1 [String],
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Get multiple nodes by ids.
Sourcefn get_neighbors<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
relation: Option<&'life2 str>,
direction: GraphDirection,
limit: usize,
include_embedding: bool,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNeighbor>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn get_neighbors<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
relation: Option<&'life2 str>,
direction: GraphDirection,
limit: usize,
include_embedding: bool,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphNeighbor>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Get neighbors of one node, optionally filtered by relation and direction.
Sourcefn shortest_path<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<GraphPath>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn shortest_path<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Option<GraphPath>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Shortest path query between source and target by BFS hops.
Sourcefn find_paths<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
top_k: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphPath>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn find_paths<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
source_id: &'life1 str,
target_id: &'life2 str,
relation: Option<&'life3 str>,
direction: GraphDirection,
max_depth: usize,
top_k: usize,
include_deleted: bool,
user_name: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<GraphPath>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Enumerate top-k shortest simple paths by BFS hops.
Sourcefn search_by_embedding<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
top_k: usize,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VecSearchHit>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn search_by_embedding<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
vector: &'life1 [f32],
top_k: usize,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<VecSearchHit>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Search by embedding vector (returns node ids + scores).
Sourcefn get_all_memory_items<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
user_name: &'life2 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn get_all_memory_items<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 str,
user_name: &'life2 str,
include_embedding: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryNode>, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Get all memory items for a scope and user.
Sourcefn update_node<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
fields: &'life2 HashMap<String, Value>,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn update_node<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
fields: &'life2 HashMap<String, Value>,
user_name: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Update fields of an existing node (memory and/or metadata).
Sourcefn delete_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn delete_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Delete a node (hard delete). If user_name is Some, implementation must verify
the node belongs to that user/cube (e.g. via metadata) before deleting; return error if not owner.
Sourcefn delete_edges_by_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<usize, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn delete_edges_by_node<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
id: &'life1 str,
user_name: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<usize, GraphStoreError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Delete all edges connected to a node. Returns number of deleted edges.