Skip to main content

graphmind_sdk/
models.rs

1//! Data models for the Graphmind SDK
2//!
3//! These types represent the API response structures and are used
4//! by both EmbeddedClient and RemoteClient.
5
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8
9/// A graph node returned from a query
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct SdkNode {
12    /// Node ID
13    pub id: String,
14    /// Node labels
15    pub labels: Vec<String>,
16    /// Node properties
17    pub properties: HashMap<String, serde_json::Value>,
18}
19
20/// A graph edge returned from a query
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct SdkEdge {
23    /// Edge ID
24    pub id: String,
25    /// Source node ID
26    pub source: String,
27    /// Target node ID
28    pub target: String,
29    /// Relationship type
30    #[serde(rename = "type")]
31    pub edge_type: String,
32    /// Edge properties
33    pub properties: HashMap<String, serde_json::Value>,
34}
35
36/// Result of executing a Cypher query
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct QueryResult {
39    /// Graph nodes referenced in the result
40    pub nodes: Vec<SdkNode>,
41    /// Graph edges referenced in the result
42    pub edges: Vec<SdkEdge>,
43    /// Column names
44    pub columns: Vec<String>,
45    /// Tabular result rows
46    pub records: Vec<Vec<serde_json::Value>>,
47}
48
49impl QueryResult {
50    /// Number of result records
51    pub fn len(&self) -> usize {
52        self.records.len()
53    }
54
55    /// Whether the result is empty
56    pub fn is_empty(&self) -> bool {
57        self.records.is_empty()
58    }
59}
60
61/// Server status information
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct ServerStatus {
64    /// Health status (e.g., "healthy")
65    pub status: String,
66    /// Server version
67    pub version: String,
68    /// Storage statistics
69    pub storage: StorageStats,
70}
71
72/// Storage statistics
73#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct StorageStats {
75    /// Number of nodes
76    pub nodes: u64,
77    /// Number of edges
78    pub edges: u64,
79}