#[non_exhaustive]pub enum Value {
Show 21 variants
Null,
Bool(bool),
Integer(i64),
Float(f64),
String(String),
Bytes(Vec<u8>),
Array(Vec<Value>),
Object(HashMap<String, Value>),
Uuid(String),
Ulid(String),
DateTime(NdbDateTime),
NaiveDateTime(NdbDateTime),
Duration(NdbDuration),
Decimal(Decimal),
Geometry(Geometry),
Set(Vec<Value>),
Regex(String),
Range {
start: Option<Box<Value>>,
end: Option<Box<Value>>,
inclusive: bool,
},
Record {
table: String,
id: String,
},
ArrayCell(ArrayCell),
Vector(Arc<[f32]>),
}Expand description
A dynamic value that can represent any field type in a document or any parameter in a SQL query.
§Serialization policy
JSON (#[serde(untagged)]) — API-boundary format, documented lossy.
JSON output uses plain JSON types ("string", 1, true, null,
[…], {…}) so that HTTP/pgwire clients see idiomatic JSON without
tagged wrappers. This is intentional but lossy for six variants:
| Variant | JSON representation | Round-trip loss |
|---|---|---|
Uuid(s) | "<s>" | decoded as String |
Ulid(s) | "<s>" | decoded as String |
Regex(s) | "<s>" | decoded as String |
Range {…} | null | decoded as Null |
Record {…} | null | decoded as Null |
ArrayCell | {"coords":[…], "attrs":[…]} | decoded as Object without type discriminator |
Vector(v) | [f32, …] (JSON number array) | decoded as Array<Float> |
Round-trip through JSON is NOT preserved for these six variants.
JSON is permitted only at the HTTP/pgwire API boundary
(decode_payload_to_json() in the Control Plane); it must never be
used for Data Plane storage, WAL records, or cross-plane messages.
zerompk MessagePack (hand-rolled ToMessagePack/FromMessagePack
in value/msgpack.rs) — internal transport format, lossless.
Every variant round-trips through MessagePack without loss. All
internal paths (Data Plane, SPSC bridge, WAL payloads) MUST use
zerompk. JSON is reserved for the API boundary and forbidden in
these contexts.
#[non_exhaustive] — new value kinds will be added in future releases
(e.g. Vector, typed collections). This attribute enforces Rust API
hygiene only; the concrete serialization contract is described above.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
SQL NULL / missing value.
Bool(bool)
Boolean.
Integer(i64)
Signed 64-bit integer.
Float(f64)
64-bit floating point.
String(String)
UTF-8 string.
Bytes(Vec<u8>)
Raw bytes (embeddings, serialized blobs).
Array(Vec<Value>)
Ordered array of values.
Object(HashMap<String, Value>)
Nested key-value object.
Uuid(String)
UUID (any version, stored as 36-char hyphenated string).
Ulid(String)
ULID (26-char Crockford Base32).
DateTime(NdbDateTime)
UTC timestamp with microsecond precision (timezone-aware).
NaiveDateTime(NdbDateTime)
Naive (local/no-timezone) timestamp with microsecond precision.
Duration(NdbDuration)
Duration with microsecond precision (signed).
Decimal(Decimal)
Arbitrary-precision decimal (financial calculations, exact arithmetic).
Geometry(Geometry)
GeoJSON-compatible geometry (Point, LineString, Polygon, etc.).
Set(Vec<Value>)
Ordered set of unique values (auto-deduplicated, maintains insertion order).
Regex(String)
Compiled regex pattern (stored as pattern string).
Range
A range of values with optional bounds.
Fields
Record
A typed reference to another record: table:id.
ArrayCell(ArrayCell)
One N-dimensional array cell (coords + attrs). Used by the array engine to carry a single cell across the SQL / wire boundary.
Vector(Arc<[f32]>)
Dense f32 embedding vector (e.g. HNSW, neural embeddings).
Stored as a reference-counted slice to allow cheap cloning without
copying the underlying floats. Serialized as raw bytes
(bytemuck::cast_slice) with zerompk tag 20; JSON serializes as a
plain number array (lossy — decodes as Array<Float>, not Vector).
Implementations§
Source§impl Value
impl Value
Sourcepub fn eq_coerced(&self, other: &Value) -> bool
pub fn eq_coerced(&self, other: &Value) -> bool
Coerced equality: Value vs Value with numeric/string coercion.
Single source of truth for type coercion in filter evaluation.
Used by matches_binary (msgpack path) and matches_value (Value path).
Sourcepub fn cmp_coerced(&self, other: &Value) -> Ordering
pub fn cmp_coerced(&self, other: &Value) -> Ordering
Coerced ordering: Value vs Value with numeric/string coercion.
Single source of truth for ordering in filter/sort evaluation.
Source§impl Value
impl Value
Sourcepub fn as_datetime(&self) -> Option<&NdbDateTime>
pub fn as_datetime(&self) -> Option<&NdbDateTime>
Try to extract as DateTime (timezone-aware).
Sourcepub fn as_naive_datetime(&self) -> Option<&NdbDateTime>
pub fn as_naive_datetime(&self) -> Option<&NdbDateTime>
Try to extract as NaiveDateTime (no timezone).
Sourcepub fn as_duration(&self) -> Option<&NdbDuration>
pub fn as_duration(&self) -> Option<&NdbDuration>
Try to extract as Duration.
Sourcepub fn as_decimal(&self) -> Option<&Decimal>
pub fn as_decimal(&self) -> Option<&Decimal>
Try to extract as Decimal.
Sourcepub fn as_geometry(&self) -> Option<&Geometry>
pub fn as_geometry(&self) -> Option<&Geometry>
Try to extract as Geometry.
Sourcepub fn as_record(&self) -> Option<(&str, &str)>
pub fn as_record(&self) -> Option<(&str, &str)>
Try to extract as a record reference (table, id).
Sourcepub fn get(&self, field: &str) -> Option<&Value>
pub fn get(&self, field: &str) -> Option<&Value>
Look up a field by name. Returns None for non-Object variants.
Sourcepub fn get_mut(&mut self, field: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, field: &str) -> Option<&mut Value>
Mutable field lookup. Returns None for non-Object variants.
Sourcepub fn as_object(&self) -> Option<&HashMap<String, Value>>
pub fn as_object(&self) -> Option<&HashMap<String, Value>>
Try to extract as an object (HashMap reference).
Sourcepub fn as_object_mut(&mut self) -> Option<&mut HashMap<String, Value>>
pub fn as_object_mut(&mut self) -> Option<&mut HashMap<String, Value>>
Try to extract as a mutable object.
Sourcepub fn as_array_iter(&self) -> Option<impl Iterator<Item = &Value>>
pub fn as_array_iter(&self) -> Option<impl Iterator<Item = &Value>>
Get array elements (for IN/array operations).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<NdbDateTime> for Value
impl From<NdbDateTime> for Value
Source§fn from(dt: NdbDateTime) -> Value
fn from(dt: NdbDateTime) -> Value
Source§impl From<NdbDuration> for Value
impl From<NdbDuration> for Value
Source§fn from(d: NdbDuration) -> Value
fn from(d: NdbDuration) -> Value
Source§impl<'a> FromMessagePack<'a> for Value
impl<'a> FromMessagePack<'a> for Value
Source§impl Serialize for Value
impl Serialize for Value
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl ToMessagePack for Value
impl ToMessagePack for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.