Skip to main content

graphmind_sdk/
client.rs

1//! GraphmindClient trait — the unified interface for embedded and remote modes
2
3use crate::error::GraphmindResult;
4use crate::models::{QueryResult, ServerStatus};
5use async_trait::async_trait;
6
7/// Unified client interface for the Graphmind graph database.
8///
9/// Implemented by:
10/// - `EmbeddedClient` — in-process, no network (for examples, tests, embedded use)
11/// - `RemoteClient` — connects to a running Graphmind server via HTTP
12#[async_trait]
13pub trait GraphmindClient: Send + Sync {
14    /// Execute a read-write Cypher query
15    async fn query(&self, graph: &str, cypher: &str) -> GraphmindResult<QueryResult>;
16
17    /// Execute a read-only Cypher query
18    async fn query_readonly(&self, graph: &str, cypher: &str) -> GraphmindResult<QueryResult>;
19
20    /// Delete a graph
21    async fn delete_graph(&self, graph: &str) -> GraphmindResult<()>;
22
23    /// List all graphs
24    async fn list_graphs(&self) -> GraphmindResult<Vec<String>>;
25
26    /// Get server status for a specific graph
27    async fn status(&self, graph: &str) -> GraphmindResult<ServerStatus>;
28
29    /// Ping the server
30    async fn ping(&self) -> GraphmindResult<String>;
31
32    /// Return a schema summary (node types, edge types, counts)
33    async fn schema(&self, graph: &str) -> GraphmindResult<String>;
34
35    /// Return the EXPLAIN plan for a Cypher query without executing it
36    async fn explain(&self, graph: &str, cypher: &str) -> GraphmindResult<QueryResult>;
37
38    /// Execute a Cypher query with PROFILE instrumentation
39    async fn profile(&self, graph: &str, cypher: &str) -> GraphmindResult<QueryResult>;
40}