cratestack_core/value.rs
1//! Backend-agnostic JSON-shaped value used throughout the framework
2//! (auth claims, audit payloads, RPC error details, schema config).
3
4use std::collections::BTreeMap;
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub enum Value {
10 Null,
11 Bool(bool),
12 Int(i64),
13 Float(f64),
14 String(String),
15 Bytes(Vec<u8>),
16 List(Vec<Value>),
17 Map(BTreeMap<String, Value>),
18}
19
20/// `Default` is required by every generated model struct since #51
21/// (column projection): non-selected fields hold `T::default()` so the
22/// returned `Projection<T>` is constructable without re-fetching.
23/// `Value::Null` is the natural identity — JSON columns surfacing as
24/// `cratestack::Value` default to "no payload" until the next read.
25impl Default for Value {
26 fn default() -> Self {
27 Value::Null
28 }
29}