1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
/*
* kglite-c — C ABI for the kglite knowledge graph engine.
*
* Generated by cbindgen. Do NOT edit by hand. To regenerate:
* cargo build -p kglite-c
* (the crate's build.rs runs cbindgen automatically).
*
* Conventions: see docs/rust/c-abi.md in the kglite repo.
* https://github.com/kkollsga/kglite/blob/main/docs/rust/c-abi.md
*/
/**
* C-ABI-side error code. Variants 1-17 map by meaning to
* [`kglite::api::KgErrorCode`]; variants 100+ are C-ABI-specific
* (invalid UTF-8 at the boundary, null pointer, OOM — conditions
* that don't have a corresponding `KgErrorCode` because they
* can't arise from inside the engine).
*/
if __STDC_VERSION__ >= 202311L
: uint32_t
// __STDC_VERSION__ >= 202311L
;
typedef enum KgliteStatusCode KgliteStatusCode;
typedef uint32_t KgliteStatusCode;
// __STDC_VERSION__ >= 202311L
/**
* The ABI version that this build of `kglite-c` exposes. Derived at
* compile time from the crate's package version (`CARGO_PKG_VERSION_*`),
* so it tracks the engine version automatically.
*/
typedef struct KgliteAbiVersion KgliteAbiVersion;
/**
* Rust-heap statistics from kglite's tracking allocator.
*/
typedef struct KgMemStats KgMemStats;
/**
* Opaque handle for an embedder. See
* [`KgliteGraph`](crate::KgliteGraph) for the rationale on the
* empty `#[repr(C)]` facade pattern — cbindgen renders only a
* forward declaration; the actual state lives in
* [`EmbedderState`].
*/
typedef struct KgliteEmbedder KgliteEmbedder;
/**
* Opaque handle for a session. See [`KgliteGraph`](crate::KgliteGraph)
* for the rationale on the empty `#[repr(C)]` facade pattern.
*/
typedef struct KgliteSession KgliteSession;
/**
* Opaque handle for a knowledge graph. The C-side caller only
* ever sees `KgliteGraph*`; allocation, deallocation, and field
* access happen inside `kglite-c`.
*
* cbindgen sees the `#[repr(C)]` empty struct and renders only a
* forward declaration in `kglite.h`. The actual state lives in
* the private [`GraphState`] sidecar: every `*mut KgliteGraph`
* the C side holds is really a `*mut GraphState` cast through
* the opaque facade.
*/
typedef struct KgliteGraph KgliteGraph;
/**
* Opaque handle for a Cypher result. See
* [`KgliteGraph`](crate::KgliteGraph) for the rationale on the
* empty `#[repr(C)]` facade pattern — cbindgen renders only a
* forward declaration; the actual state lives in [`ResultState`].
*/
typedef struct KgliteCypherResult KgliteCypherResult;
/**
* Return the C ABI version this library was built against.
* Bindings should call this on startup and refuse to proceed if
* the major version doesn't match what they were compiled
* against — a mismatched major risks segfaults from changed
* struct layouts or removed functions.
*
* Conventions within a major version: additive only (new
* functions, new status codes, new opaque types). Existing
* function signatures and struct layouts never change.
*
* # Examples
*
* ```c
* KgliteAbiVersion v = kglite_abi_version();
* if (v.major != KGLITE_EXPECTED_MAJOR) {
* fprintf(stderr, "kglite ABI mismatch: expected %u.x, got %u.%u.%u\n",
* KGLITE_EXPECTED_MAJOR, v.major, v.minor, v.patch);
* return 1;
* }
* ```
*/
struct KgliteAbiVersion ;
/**
* Return current Rust-heap statistics from kglite's tracking allocator.
* Counts only allocations through the Rust global allocator — the host
* runtime's own heap is separate. Useful for a binding to surface
* kglite's memory footprint in its own metrics.
*/
struct KgMemStats ;
/**
* Free an embedder handle. Idempotent on null.
*
* # Safety
*
* `embedder` must be either null or a valid pointer previously
* returned by a `kglite_embedder_*_new` factory and not yet
* freed. Calling twice on the same pointer is UB.
*
* **Do NOT free** an embedder that has been handed to
* [`kglite_session_set_embedder`] — the session retains a clone
* of the inner Arc; you may free your handle after the call to
* set_embedder (the Arc keeps the embedder alive until the
* session drops). For symmetry with other handles, the safest
* pattern is: factory → set_embedder → free_embedder. Once the
* Arc is shared, the original handle is no longer special.
*/
void ;
/**
* Attach an embedder to a session. The session retains a clone
* of the embedder's inner `Arc`, so subsequent
* [`kglite_session_execute_read`](crate::kglite_session_execute_read)
* calls have access to `text_score()` and other embedder-backed
* Cypher functions.
*
* The caller may free the embedder handle after this call
* returns — the `Arc` clone keeps the underlying embedder
* alive for the session's lifetime.
*
* # Safety
*
* `session` and `embedder` must be valid handles previously
* returned by `kglite_session_new` and a `kglite_embedder_*_new`
* factory respectively, neither yet freed.
*/
KgliteStatusCode ;
/**
* Construct a fastembed-rs-backed embedder.
*
* fastembed-rs downloads ONNX model weights on first
* `embed()` call (cached at `~/.cache/fastembed/`). The factory
* does NOT block on download — model name validation only. The
* first Cypher query using `text_score()` triggers the download.
*
* # Arguments
*
* - `model_name` (in, borrowed): a known fastembed model name,
* e.g. `"BAAI/bge-m3"`, `"sentence-transformers/all-MiniLM-L6-v2"`.
* See fastembed-rs's TextEmbedding::list_supported_models() for
* the full list.
* - `out_embedder` (out, owned): on success, set to an embedder
* handle. Caller must free via [`kglite_embedder_free`] (or
* transfer ownership via [`kglite_session_set_embedder`]).
* - `out_error_msg` (out, owned, may be null): on failure, set to
* an owned error string.
*
* # Errors
*
* - `KGLITE_STATUS_CODE_NULL_POINTER` — required pointer is null
* - `KGLITE_STATUS_CODE_INVALID_UTF8` — `model_name` isn't valid UTF-8
* - `KGLITE_STATUS_CODE_INVALID_ARGUMENT` — `model_name` isn't a known
* fastembed model
*
* # Feature gate
*
* Available only when `kglite-c` is built with the `fastembed`
* Cargo feature.
*
* # Safety
*
* `model_name` must be a null-terminated UTF-8 string.
* `out_embedder` must be a valid writable pointer.
*/
KgliteStatusCode ;
/**
* Create a new, empty in-memory knowledge graph.
*
* The returned handle owns a fresh, empty `DirGraph` — the C-side
* analogue of constructing `KnowledgeGraph()` in Python. Build it up
* by opening a session ([`kglite_session_new`](crate::kglite_session_new))
* and running `CREATE` / `MERGE` Cypher through
* [`kglite_session_execute_mut`](crate::kglite_session_execute_mut), or
* by bulk-loading via the dataset / blueprint entry points. Before this
* existed, the only way to obtain a graph at the C boundary was to load
* a pre-built `.kgl` file — a binding could not start one from scratch.
*
* # Returns
*
* A non-null `KgliteGraph*` the caller must free with
* [`kglite_graph_free`], or hand to
* [`kglite_session_new`](crate::kglite_session_new) which takes
* ownership. Returns null only on allocation failure.
*/
struct KgliteGraph *;
/**
* Create a fresh, empty knowledge graph in an explicit storage mode.
*
* `mode` is `"memory"` (alias `"default"`), `"mapped"`, or `"disk"` — the
* same mode vocabulary as Python's `storage=` argument:
*
* - `"memory"` — heap-resident (the default; same as [`kglite_graph_new`]).
* - `"mapped"` — property columns spill to mmap during build, so a graph
* larger than RAM can be constructed; saves to a `.kgl` file.
* - `"disk"` — CSR + mmap on-disk directory format for very large graphs;
* **requires** `path` (the directory that becomes the graph).
*
* This is the create/ingest entry point. Opening an existing graph
* ([`kglite_load_file`]) auto-detects its mode, so no mode argument is
* needed there.
*
* # Arguments
*
* - `mode` (in, borrowed): UTF-8 mode string, null-terminated.
* - `path` (in, borrowed): UTF-8 directory path for `"disk"`, else null.
* - `out_graph` (out, owned): set to the new graph handle on success
* (free via [`kglite_graph_free`], or hand to
* [`kglite_session_new`](crate::kglite_session_new)); null on failure.
* - `out_error_msg` (out, owned): owned error message on failure (free via
* [`kglite_free_string`](crate::kglite_free_string)); null on success.
*
* # Errors
*
* - `KGLITE_ERR_NULL_POINTER` — `mode` or `out_graph` is null
* - `KGLITE_ERR_INVALID_UTF8` — `mode` / `path` isn't valid UTF-8
* - `KGLITE_ERR_INVALID_ARGUMENT` — unknown mode, or `"disk"` with no path
* - `KGLITE_ERR_FILE_IO` — failed to create the disk-graph directory
*
* # Safety
*
* `mode` must be a null-terminated UTF-8 string; `path` null or the same;
* `out_graph` a valid `*mut KgliteGraph` slot; `out_error_msg` null or a
* valid slot.
*/
KgliteStatusCode ;
/**
* Load a knowledge graph from disk. Accepts `.kgl` files
* (single-file mmap format) and directories (disk-backed CSR
* layout) — the loader picks the right path based on what's at
* `path`.
*
* # Arguments
*
* - `path` (in, borrowed): UTF-8 file path, null-terminated.
* - `out_graph` (out, owned): set to the loaded graph handle on
* success; caller must free via [`kglite_graph_free`]. Set to
* null on failure.
* - `out_error_msg` (out, owned): set to an owned error message
* on failure; caller must free via
* [`kglite_free_string`](crate::kglite_free_string). Set to
* null on success.
*
* # Errors
*
* - `KGLITE_ERR_NULL_POINTER` — `path` or `out_graph` is null
* - `KGLITE_ERR_INVALID_UTF8` — `path` isn't valid UTF-8
* - `KGLITE_ERR_FILE_NOT_FOUND` — `path` doesn't exist
* - `KGLITE_ERR_FILE_FORMAT` — file isn't a valid `.kgl` /
* disk-graph directory
* - `KGLITE_ERR_FILE_IO` — I/O failure during read
*
* # Safety
*
* `path` must point to a null-terminated UTF-8 string.
* `out_graph` must be a valid writable pointer to a
* `*mut KgliteGraph` slot. `out_error_msg` may be null (the
* caller doesn't care about the message); otherwise it must
* point to a valid writable `*const c_char` slot.
*/
KgliteStatusCode ;
/**
* Load an RDF file into a fresh in-memory graph — the C-side handle on
* the wheel's `kglite.load_rdf`. Dispatches on the extension: `.ttl`
* (Turtle), `.nt` (N-Triples), `.nq` (N-Quads), `.trig` (TriG).
*
* The RDF → property-graph fold: object literals become typed node
* properties, resource objects become edges, and `rdf:type` sets the
* node label (first wins; extras kept in an `rdf_types` property).
* Predicate / type IRIs are CURIE-compacted with a `__` separator
* (so `[:foaf__knows]` matches in Cypher); each node keeps its full
* subject IRI in a `uri` property. In-memory backend only.
*
* # Arguments
*
* - `path` (in, borrowed): UTF-8 file path; the extension picks the parser.
* - `languages_json` (in, borrowed): JSON array of language tags to keep
* (e.g. `["en","de"]`), or null to keep all literals.
* - `label_predicates_json` (in, borrowed): JSON array of predicate IRIs
* whose literal object sets the node title, or null for
* `["http://www.w3.org/2000/01/rdf-schema#label"]`.
* - `keep_full_iris` (in): non-zero keeps full IRIs instead of CURIEs.
* - `default_type` (in, borrowed): node type for subjects without an
* `rdf:type`, or null for `"Resource"`.
* - `max_triples` (in): stop after this many triples; negative = no limit.
* - `out_graph` (out, owned): the loaded graph on success (free via
* [`kglite_graph_free`] or hand to
* [`kglite_session_new`](crate::kglite_session_new)); null on failure.
* - `out_stats_json` (out, owned): `{"nodes":N,"edges":M,"triples":T}` on
* success — free via [`kglite_free_string`](crate::kglite_free_string).
* May be null if the caller doesn't want stats.
* - `out_error_msg` (out, owned): error message on failure — free via
* [`kglite_free_string`](crate::kglite_free_string); null on success.
*
* # Errors
*
* - `KGLITE_ERR_NULL_POINTER` — `path` or `out_graph` is null
* - `KGLITE_ERR_INVALID_UTF8` — a string argument isn't valid UTF-8
* - `KGLITE_ERR_INVALID_ARGUMENT` — a `*_json` arg isn't a JSON string
* array, or the file extension isn't a supported RDF format
* - `KGLITE_ERR_FILE_NOT_FOUND` — `path` doesn't exist
* - `KGLITE_ERR_FILE_FORMAT` — a parse error in the RDF
*
* # Safety
*
* String arguments must each be a null-terminated UTF-8 string or null;
* `out_graph` a valid writable `*mut KgliteGraph` slot; `out_stats_json`
* and `out_error_msg` null or valid writable slots.
*/
KgliteStatusCode ;
/**
* Save a knowledge graph to disk. The on-disk format depends on
* the underlying storage mode — in-memory and mapped graphs
* produce a `.kgl` single-file; disk-backed graphs produce / fill
* a directory.
*
* The write is atomic (temp + rename) and **durable** (file +
* parent-directory fsync) — a crash mid-save can't tear the file.
* Use [`kglite_save_graph_durable`] with `fsync == 0` for the fast,
* non-durable opt-out.
*
* # Arguments
*
* - `graph` (in, borrowed): the graph to save.
* - `path` (in, borrowed): UTF-8 destination path,
* null-terminated.
* - `out_error_msg` (out, owned): set to an owned error message
* on failure; caller must free via
* [`kglite_free_string`](crate::kglite_free_string). Set to
* null on success.
*
* # Errors
*
* - `KGLITE_ERR_NULL_POINTER` — `graph` or `path` is null
* - `KGLITE_ERR_INVALID_UTF8` — `path` isn't valid UTF-8
* - `KGLITE_ERR_FILE_IO` — write failed
*
* # Safety
*
* `graph` must be a valid `*mut KgliteGraph` previously returned
* by a `kglite_*` function and not yet freed. `path` must be a
* null-terminated UTF-8 string.
*/
KgliteStatusCode ;
/**
* Free a graph handle. Idempotent on null (no-op).
*
* # Safety
*
* `graph` must be either null or a pointer previously returned by
* [`kglite_load_file`] (or any future `kglite_*` function that
* returns a `*mut KgliteGraph`) and not yet freed. Calling twice
* on the same pointer is UB.
*
* **Do NOT free** a graph handle that has been handed to
* [`kglite_session_new`](crate::kglite_session_new) — the session
* takes ownership and frees on its own teardown.
*/
void ;
/**
* Generate a synthetic benchmark/demo graph as CSVs + a manifest under
* `out_dir`, in bounded memory. Load the result with [`kglite_load_file`]
* pointed at `out_dir` — the C-side handle on `kglite.graphgen(...)`, the
* "hello, query a graph" data source for a fresh binding.
*
* `zipf` != 0 uses a Zipf degree distribution (high-degree hubs) with
* exponent `zipf_exp`; `zipf` == 0 uses uniform degree.
*
* On success `out_stats_json` is set to an owned `{"nodes": N, "edges": M}`
* string — free via [`kglite_free_string`](crate::kglite_free_string).
*
* # Safety
*
* `out_dir` must be a null-terminated UTF-8 path; `out_stats_json` a valid
* writable `*const c_char` slot; `out_error_msg` null or a valid slot.
*/
KgliteStatusCode ;
/**
* Build a graph declaratively from a blueprint file + a directory of
* CSVs — the C-side handle on the wheel's `from_blueprint`. Loads the
* JSON/YAML blueprint at `blueprint_path`, builds into a fresh graph
* reading CSVs relative to `csv_dir`, and returns the populated graph.
*
* On success `out_graph` is set to a `KgliteGraph*` (free via
* [`kglite_graph_free`] or hand to [`kglite_session_new`](crate::kglite_session_new)),
* and `out_report_json` to an owned
* `{"nodes_by_type":{..},"edges_by_type":{..},"warnings":[..],"errors":[..],"provisional_purged":N}`
* string — free via [`kglite_free_string`](crate::kglite_free_string).
*
* # Safety
*
* `blueprint_path` / `csv_dir` must be null-terminated UTF-8 paths;
* `out_graph` / `out_report_json` valid writable slots; `out_error_msg`
* null or a valid slot.
*/
KgliteStatusCode ;
/**
* Save a graph to a `.kgl` file with an explicit durability choice.
*
* `fsync` != 0 is exactly [`kglite_save_graph`]: mode-aware (disk dir vs
* in-memory `.kgl`), atomic temp+rename, and the file + parent directory
* are flushed to stable storage before returning — durable across power
* loss, at the cost of fsync latency.
*
* `fsync` == 0 is the fast, **non-durable** opt-out: same mode-aware
* atomic rename (never a torn file) but the fsync barrier is skipped, so
* the bytes may not survive an OS/power crash. Use it only for bulk or
* throwaway saves where you'll re-save or can rebuild.
*
* # Safety
*
* `graph` must be a valid handle; `path` a null-terminated UTF-8 path;
* `out_error_msg` null or a valid slot.
*/
KgliteStatusCode ;
/**
* Serialize a graph to an in-memory `.kgl` byte buffer (no file). On
* success `*out_buf` / `*out_len` describe an owned buffer the caller
* MUST free with [`kglite_free_bytes`]. Pair with
* [`kglite_graph_from_bytes`] to round-trip a graph through bytes (IPC,
* object storage, …).
*
* # Safety
*
* `graph` valid; `out_buf` a valid `*mut u8` slot; `out_len` a valid
* `usize` slot; `out_error_msg` null or valid.
*/
KgliteStatusCode ;
/**
* Free a byte buffer returned by [`kglite_graph_to_bytes`]. Pass the
* same `buf` / `len` pair. Null `buf` is a no-op.
*
* # Safety
*
* `buf` / `len` must be a pair previously returned by
* [`kglite_graph_to_bytes`] and not yet freed.
*/
void ;
/**
* Load a graph from an in-memory `.kgl` byte buffer — the inverse of
* [`kglite_graph_to_bytes`].
*
* # Safety
*
* `data` / `len` must describe a readable buffer; `out_graph` a valid
* writable slot; `out_error_msg` null or a valid slot.
*/
KgliteStatusCode ;
/**
* Compute a JSON schema overview of a graph: node types (count +
* property types), connection types (endpoints + property names),
* indexes, and total node/edge counts. The C-side handle on the
* agent-facing schema — call it right after load / build / from_bytes
* to learn a graph's shape before querying.
*
* On success `out_json` is set to an owned JSON object — free via
* [`kglite_free_string`](crate::kglite_free_string). Operates on a graph
* handle (before it is moved into a session).
*
* # Safety
*
* `graph` must be a valid handle; `out_json` a valid writable slot;
* `out_error_msg` null or a valid slot.
*/
KgliteStatusCode ;
/**
* Return the column names as a JSON array string:
* `["col1", "col2", ...]`.
*
* The returned string is OWNED by the caller and must be freed
* via [`kglite_free_string`](crate::kglite_free_string). Returns
* null on serialization failure (shouldn't happen — column names
* are always serializable).
*
* # Safety
*
* `result` must be null or a live pointer returned by a kglite query
* function. It must not be freed while this call is running.
*/
const char *;
/**
* Return all rows as a JSON array of objects keyed by column
* name: `[{"col1": v1, "col2": v2}, ...]`.
*
* Cell values are **natural** JSON (`2`, `"x"`, `[..]`, `{..}`) via
* [`kglite_value_to_json`](kglite::api::param::kglite_value_to_json) —
* not serde's externally-tagged enum encoding — so a binding parses
* `{"n": 2}`, not `{"n": {"Int64": 2}}`.
*
* For large result sets this materializes the entire JSON blob
* in memory. Future v2 will add pull-row-by-row accessors; for
* now this is fine for the common-case query sizes.
*
* The returned string is OWNED by the caller and must be freed
* via [`kglite_free_string`](crate::kglite_free_string). Returns
* null on serialization failure.
*
* # Safety
*
* `result` must be null or a live pointer returned by a kglite query
* function. It must not be freed while this call is running.
*/
const char *;
/**
* Return the number of rows in the result. Useful for callers
* that want to size buffers before requesting the JSON blob.
*
* # Safety
*
* `result` must be null or a live pointer returned by a kglite query
* function. It must not be freed while this call is running.
*/
uintptr_t ;
/**
* Free a result handle. Idempotent on null (no-op).
*
* # Safety
*
* `result` must be either null or a valid pointer previously
* returned by [`kglite_session_execute_read`](crate::kglite_session_execute_read)
* or [`kglite_session_execute_mut`](crate::kglite_session_execute_mut)
* and not yet freed.
*/
void ;
/**
* Create a new session from a graph handle. The session takes
* ownership of the graph — the caller MUST NOT call
* [`kglite_graph_free`](crate::kglite_graph_free) on the handle
* after this call. Free the session via
* [`kglite_session_free`] when done.
*
* # Arguments
*
* - `graph` (in, MOVED): graph handle. After this call, the
* pointer is no longer valid for any other use.
* - `out_session` (out, owned): set to the session handle on
* success; caller must free via [`kglite_session_free`].
*
* # Errors
*
* - `KGLITE_ERR_NULL_POINTER` — `graph` or `out_session` is null
*
* # Safety
*
* `graph` must be a valid `*mut KgliteGraph` previously returned
* by [`kglite_load_file`](crate::kglite_load_file) and not yet
* freed or moved into another session. `out_session` must be a
* valid writable pointer to a `*mut KgliteSession` slot.
*/
KgliteStatusCode ;
/**
* Run a read-only Cypher query.
*
* # Arguments
*
* - `session` (in, borrowed): the session.
* - `query` (in, borrowed): UTF-8 Cypher query, null-terminated.
* - `params_json` (in, borrowed, may be null): JSON object of
* parameter bindings. Pass null or `"{}"` for no params.
* - `out_result` (out, owned): on success, set to the result
* handle; caller must free via [`kglite_cypher_result_free`].
* - `out_error_msg` (out, owned, may be null): on failure, set
* to the error message; caller must free via
* [`kglite_free_string`](crate::kglite_free_string).
*
* # Errors
*
* Any `KgErrorCode` variant — Cypher syntax / type mismatch /
* timeout / execution error / node-not-found / argument
* validation. The error message describes the specific failure.
*
* # Safety
*
* `session` must be valid. `query` and (if non-null) `params_json`
* must be null-terminated UTF-8 strings.
*/
KgliteStatusCode ;
/**
* Run a read-only Cypher query with execution options. Same as
* [`kglite_session_execute_read`], plus:
*
* - `timeout_ms`: past this wall-clock budget the query returns
* `CypherTimeout`. `0` = no deadline.
* - `max_rows`: reject the query (error) if it would produce more than
* this many rows — a safety guard against runaway results, not a
* silent truncation; add a `LIMIT` clause to bound output. `0` = no
* limit.
*
* # Safety
*
* Same as [`kglite_session_execute_read`].
*/
KgliteStatusCode ;
/**
* Run a mutating Cypher query. Same shape as
* [`kglite_session_execute_read`] but accepts CREATE / SET /
* DELETE / REMOVE / MERGE statements. The session's underlying
* graph is auto-committed after a successful execute (no
* explicit begin/commit in v1 — explicit transactions land in
* a future ABI version once a binding needs them).
*
* # Safety
*
* Same as [`kglite_session_execute_read`] except `session` is
* declared as `*mut` (the call mutates the session's interior
* graph via commit-swap).
*/
KgliteStatusCode ;
/**
* Run a mutating query with the same timeout and row/collection budget
* semantics as [`kglite_session_execute_read_opts`]. A budget failure rolls
* back the complete statement. `0` disables the corresponding option.
*
* # Safety
*
* Same as [`kglite_session_execute_mut`].
*/
KgliteStatusCode ;
/**
* Run several read-only Cypher queries against a single consistent
* snapshot, in one lock acquisition.
*
* `queries_json` is a JSON array of objects, each `{"query": "...",
* "params": {...}}` (the `params` key is optional). Every query sees
* the same snapshot, taken once up front — cheaper and more consistent
* than N separate [`kglite_session_execute_read`] calls when a binding
* issues many small reads.
*
* On success `out_results_json` is set to an owned JSON string: an
* array of `{"columns": [...], "rows": [{...}]}` objects, one per input
* query in order, with the same natural-value encoding as
* [`kglite_cypher_result_rows_json`]. Free it with
* [`kglite_free_string`](crate::kglite_free_string).
*
* The batch aborts on the first failing query: `out_results_json` is
* set to null and the status code / `out_error_msg` describe that
* query's failure.
*
* # Safety
*
* `session` must be valid; `queries_json` a null-terminated UTF-8 JSON
* array; `out_results_json` a valid writable `*const c_char` slot;
* `out_error_msg` null or a valid writable slot.
*/
KgliteStatusCode ;
/**
* Run several mutating Cypher queries in a single transaction — one
* `begin`, N executes (each sees the previous query's writes), a single
* `commit`. The batch is **atomic**: if any query fails, the
* transaction is dropped uncommitted and none of the batch's mutations
* reach the graph.
*
* `queries_json` / `out_results_json` have the same shape as
* [`kglite_session_execute_read_batch`]. On failure `out_results_json`
* is null and the status / `out_error_msg` describe the failing query.
*
* # Safety
*
* Same as [`kglite_session_execute_read_batch`] except `session` is
* `*mut` (the call mutates the session's interior graph via
* commit-swap).
*/
KgliteStatusCode ;
/**
* Bulk-create edges addressed by **stable node id + type**, bypassing
* Cypher — the fast ingest path for bindings loading many edges.
*
* `edges_json` is a JSON array of objects:
* `{"src_id": <id>, "src_type": "Person", "dst_id": <id>,
* "dst_type": "Company", "type": "WORKS_AT", "props": {...}}`
* (`props` optional). `src_id`/`dst_id` are the nodes' stable ids (the
* same value `n.id` returns), not internal indices. Runs in one
* transaction: the whole batch commits together, or — on error — none
* of it lands. Endpoints must already exist; an edge whose source or
* target id isn't found for its declared type is skipped and counted.
*
* On success `out_report_json` is set to an owned JSON object
* `{"connections_created": N, "skipped_missing_endpoint": M}`; free it
* with [`kglite_free_string`](crate::kglite_free_string).
*
* This wraps the shared core primitive
* [`add_edges_from_specs`](kglite::api::mutation::add_edges_from_specs) —
* the same engine the Python `add_connections` DataFrame path uses.
*
* # Safety
*
* `session` must be valid; `edges_json` a null-terminated UTF-8 JSON
* array; `out_report_json` a valid writable `*const c_char` slot;
* `out_error_msg` null or a valid writable slot.
*/
KgliteStatusCode ;
/**
* Free a session handle. Idempotent on null (no-op).
*
* # Safety
*
* `session` must be either null or a valid pointer previously
* returned by [`kglite_session_new`] and not yet freed.
*/
void ;
/**
* Return the canonical human-readable name of a status code (e.g.
* `"CypherSyntax"`, `"NodeNotFound"`, `"InvalidUtf8"`).
*
* The returned string is OWNED by the caller and must be freed
* via [`kglite_free_string`](crate::kglite_free_string). Returns
* null on `Ok` (no error to name).
*/
const char *;
/**
* Return the Neo4j wire status code for a status code (e.g.
* `"Neo.ClientError.Statement.SyntaxError"`). Useful for bindings
* implementing the Neo4j Bolt wire protocol or compatible HTTP
* APIs.
*
* The returned string is OWNED by the caller and must be freed
* via [`kglite_free_string`](crate::kglite_free_string). Returns
* null on `Ok` or on C-ABI-only error codes that have no Neo4j
* counterpart (`InvalidUtf8`, `NullPointer`).
*/
const char *;
/**
* Return the HTTP status code mapping for a status code (e.g.
* 400 for `CypherSyntax`, 404 for `NodeNotFound`, 500 for
* `Internal`). Useful for REST/gRPC bindings.
*
* Returns 0 for `Ok` and 500 for C-ABI-only codes (`InvalidUtf8`
* = 400 / bad request from caller, `NullPointer` = 400).
*/
uint16_t ;
/**
* Free a string previously returned by any `kglite_*` function.
*
* # Safety
*
* `s` must be either null or a pointer previously returned
* by a `kglite_*` function (these all flow through
* [`alloc_c_string`]). Calling twice on the same pointer is UB.
* Calling with a pointer to a string allocated by the C caller's
* own `malloc` is UB.
*
* Passing null is safe (treated as a no-op).
*
* # Examples
*
* ```c
* const char* col_json = kglite_cypher_result_columns_json(result);
* printf("%s\n", col_json);
* kglite_free_string(col_json);
* ```
*/
void ;
/* KGLITE_H_INCLUDED */