Skip to content

Commit 3f828e2

Browse files
committed
style: rearrange kuzu.rs into sections
1 parent 9e6f815 commit 3f828e2

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/ops/storages/kuzu.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,36 @@ use crate::prelude::*;
1212
use crate::setup::{ResourceSetupStatus, SetupChangeType};
1313
use crate::{ops::sdk::*, setup::CombinedState};
1414

15+
const SELF_CONTAINED_TAG_FIELD_NAME: &str = "__self_contained";
16+
17+
////////////////////////////////////////////////////////////
18+
// Public Types
19+
////////////////////////////////////////////////////////////
20+
1521
#[derive(Debug, Deserialize, Clone)]
1622
pub struct ConnectionSpec {
1723
/// The URL of the [Kuzu API server](https://kuzu.com/docs/api/server/overview),
1824
/// e.g. `http://localhost:8000`.
1925
api_server_url: String,
2026
}
2127

22-
type KuzuGraphElement = GraphElementType<ConnectionSpec>;
23-
2428
#[derive(Debug, Deserialize)]
2529
pub struct Spec {
2630
connection: spec::AuthEntryReference<ConnectionSpec>,
2731
mapping: GraphElementMapping,
2832
}
2933

34+
#[derive(Debug, Deserialize)]
35+
pub struct Declaration {
36+
connection: spec::AuthEntryReference<ConnectionSpec>,
37+
#[serde(flatten)]
38+
decl: GraphDeclaration,
39+
}
40+
41+
////////////////////////////////////////////////////////////
42+
// Utils to deal with Kuzu
43+
////////////////////////////////////////////////////////////
44+
3045
struct CypherBuilder {
3146
query: String,
3247
params: Vec<(String, serde_json::Value)>,
@@ -49,13 +64,6 @@ impl CypherBuilder {
4964
}
5065
}
5166

52-
#[derive(Debug, Deserialize)]
53-
pub struct Declaration {
54-
connection: spec::AuthEntryReference<ConnectionSpec>,
55-
#[serde(flatten)]
56-
decl: GraphDeclaration,
57-
}
58-
5967
struct KuzuThinClient {
6068
reqwest_client: reqwest::Client,
6169
query_url: String,
@@ -94,8 +102,6 @@ impl KuzuThinClient {
94102
}
95103
}
96104

97-
const SELF_CONTAINED_TAG_FIELD_NAME: &str = "__self_contained";
98-
99105
fn kuzu_table_type(elem_type: &ElementType) -> &'static str {
100106
match elem_type {
101107
ElementType::Node(_) => "NODE",
@@ -152,6 +158,10 @@ fn value_type_to_kuzu(value_type: &ValueType) -> Result<String> {
152158
})
153159
}
154160

161+
////////////////////////////////////////////////////////////
162+
// Setup
163+
////////////////////////////////////////////////////////////
164+
155165
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
156166
struct ReferencedNodeTable {
157167
table_name: String,
@@ -289,6 +299,12 @@ impl GraphElementDataSetupStatus {
289299
}
290300
}
291301

302+
////////////////////////////////////////////////////////////
303+
// Factory implementation
304+
////////////////////////////////////////////////////////////
305+
306+
type KuzuGraphElement = GraphElementType<ConnectionSpec>;
307+
292308
pub struct Factory {
293309
reqwest_client: reqwest::Client,
294310
}

0 commit comments

Comments
 (0)