Skip to main content

sqlitegraph/backend/sqlite/
types.rs

1//! Type definitions for SQLite backend operations.
2//!
3//! This module contains all input specification types, query configurations,
4//! and direction enumerations needed for graph operations through the SQLite backend.
5
6use serde::{Deserialize, Serialize};
7
8/// Direction specification for graph traversal operations.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
10pub enum BackendDirection {
11    Outgoing,
12    Incoming,
13}
14
15/// Query configuration for neighbor lookups with optional filtering.
16#[derive(Clone, Debug)]
17pub struct NeighborQuery {
18    pub direction: BackendDirection,
19    pub edge_type: Option<String>,
20}
21
22impl Default for NeighborQuery {
23    fn default() -> Self {
24        Self {
25            direction: BackendDirection::Outgoing,
26            edge_type: None,
27        }
28    }
29}
30
31/// Node specification for insertion operations.
32#[derive(Clone, Debug)]
33pub struct NodeSpec {
34    pub kind: String,
35    pub name: String,
36    pub file_path: Option<String>,
37    pub data: serde_json::Value,
38}
39
40/// Edge specification for insertion operations.
41#[derive(Clone, Debug)]
42pub struct EdgeSpec {
43    pub from: i64,
44    pub to: i64,
45    pub edge_type: String,
46    pub data: serde_json::Value,
47}