Skip to main content

graphmind_sdk/
client.rs

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