Skip to main content

meshdb_executor/
value.rs

1use meshdb_core::{Edge, Node, Property};
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub enum Value {
7    Node(Node),
8    Edge(Edge),
9    Property(Property),
10    List(Vec<Value>),
11    /// A Cypher map that can hold any `Value` — including graph
12    /// elements (`Node`, `Edge`, `Path`) which `Property::Map`
13    /// can't represent. Only constructed by `Expr::Map` when one
14    /// of the entries evaluates to a non-`Property` shape
15    /// (e.g. `{u: node_u}`). Purely-scalar map literals still
16    /// lower to `Value::Property(Property::Map(...))` so node /
17    /// edge property storage and the wire format stay
18    /// unchanged.
19    Map(std::collections::HashMap<String, Value>),
20    /// A Cypher path — a materialized traversal produced by
21    /// `MATCH p = (...)-[...]->(...)`. The invariant is
22    /// `nodes.len() == edges.len() + 1`; a zero-hop path
23    /// (`MATCH p = (n)`) has one node and zero edges. Stored
24    /// alongside the other Value variants (rather than inside
25    /// `Property`) because paths carry full Node/Edge values
26    /// which the backend-neutral `Property` type can't hold.
27    Path {
28        nodes: Vec<Node>,
29        edges: Vec<Edge>,
30    },
31    Null,
32}
33
34pub type Row = HashMap<String, Value>;
35
36/// Per-query parameter bindings, e.g. `$name → "Ada"`. Built once per
37/// `execute_with_reader` call and threaded through every `eval_expr`
38/// invocation so `Expr::Parameter(name)` resolves to a concrete value.
39pub type ParamMap = HashMap<String, Value>;