pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
Str(String),
List(Vec<Value>),
Record(Vec<(String, Value)>),
Instant {
secs: i64,
nanos: u32,
offset_min: Option<i16>,
},
Duration {
secs: i64,
nanos: u32,
},
Quantity {
value: f64,
base: String,
written: Option<(f64, String)>,
},
}Expand description
A projected scalar value.
Variants§
Null
Absent / undefined.
Bool(bool)
A boolean (e.g. :::is-leaf).
Int(i64)
An integer (e.g. ;;;size, :::index).
Float(f64)
A floating-point number.
Str(String)
A string (e.g. :::name, file content).
List(Vec<Value>)
A list of values (produced by aggregating pipeline functions).
Record(Vec<(String, Value)>)
A record: insertion-ordered named fields (spec: The Record
Scalar). Constructed by record(...); field order is
significant, matching kaiv namespaces and JSON key order.
Instant
A point on the UTC timeline (spec: The Temporal Fragment).
offset_min preserves the source’s UTC offset for display
only — comparison is always on the timeline. Displays as
ISO-8601; a midnight instant with no offset prints as a
bare date.
Duration
A span of time (instant minus instant; the days(n) family).
Displays as an ISO-8601 duration (P1DT2H).
Quantity
A value on a dimension (spec: The Quantital Fragment):
the magnitude scaled to the dimension’s SI-base expansion
(base, e.g. m, kg*m^2/s^3), the written form kept
for display only — exactly as instants keep their written
offset. Minted by unit-aware adapters (kaiv); compared and
combined on the base, so 42 km orders above 5000 m.
Implementations§
Source§impl Value
impl Value
Sourcepub fn bytes(n: i64) -> Value
pub fn bytes(n: i64) -> Value
A byte count as a typed quantity on the information base —
the mint for every adapter’s size fact, so [;;;size > 1GiB], | convert(MB), and typed size totals work
uniformly. (Exact up to 2^53 bytes — 8 PiB — beyond which
f64 granularity coarsens; no substrate this engine mounts
reports single objects there.)
Sourcepub fn is_truthy(&self) -> bool
pub fn is_truthy(&self) -> bool
Truthiness, for predicate coercion: Null, false, 0, the
empty string, and the empty list and record are falsy;
everything else is truthy.
Sourcepub fn temporal_reading(&self) -> Option<(i64, u32)>
pub fn temporal_reading(&self) -> Option<(i64, u32)>
The temporal reading (spec: The Temporal Fragment): the UTC timeline point a value denotes, if any — an instant itself, an integer or float read as epoch seconds, or ISO-8601 text. Booleans, lists, records, durations, and non-ISO text have none.
Sourcepub fn unital_reading(&self) -> Option<(f64, String)>
pub fn unital_reading(&self) -> Option<(f64, String)>
The unital reading (spec: The Unital Reading): the
dimensioned magnitude a value denotes, if any — a quantity
itself, or unit text (5km, 0.2 kW) scaled through the
frozen built-in table. Bare numbers read as the partner’s
base at the comparison site (they carry no dimension of
their own), so they are not read here.
Sourcepub fn durational_reading(&self) -> Option<(i64, u32)>
pub fn durational_reading(&self) -> Option<(i64, u32)>
The durational reading (spec: The Durational Reading): the
span a value denotes, if any — a duration itself, a number
read as seconds, or span text (an ISO-8601 duration or a
systemd time-span like 5d3h5min). Booleans, lists, records,
instants, and other text have none.
Sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Strict-JSON rendering: strings quoted and escaped, numbers and
booleans bare, null literal, lists as arrays, records as
key-ordered JSON objects. This is the | json serialization
and the display form of records, making a record stream
JSONL.
Sourcepub fn numeric(&self) -> Option<f64>
pub fn numeric(&self) -> Option<f64>
The numeric value, for numeric comparison and aggregation.
Int and Float coerce, and so does a string that parses as a
finite number,—,without which numeric work would silently
fail over text adapters, where every value is a string (an HTML
attribute like rank="3", a CSV cell). Non-numeric strings,
booleans, lists, and null do not coerce.
Sourcepub fn numeric_reading(&self) -> Option<Value>
pub fn numeric_reading(&self) -> Option<Value>
The numeric reading (spec: The Numeric Fragment) — like
Value::numeric, but type-preserving: text with integer
form reads as an exact Int, so arithmetic over text-sourced
values stays exact. At most one reading exists; booleans,
lists, and null have none.
Sourcepub fn compare(&self, other: &Value) -> Ordering
pub fn compare(&self, other: &Value) -> Ordering
A total order for sorting — transitive by construction, via
a per-value canonical key (see [SortKey]): null, then
booleans, then the magnitude line (numbers, instants as
epoch seconds, durations as seconds, quantities as their
base magnitude, and text through its one reading — the text
readings are disjoint by grammar), then readingless text,
then lists and records by display form. Values meeting on
the line compare by magnitude alone, so 60, PT1M, and a
same-point instant are equal — the price of transitive
equality (group already keys 60 and PT1M together).
Ordering contexts with an adapter at hand should call
Value::compare_with so mounted custom units read; this
wrapper uses the frozen built-in table.
Sourcepub fn compare_with(
&self,
other: &Value,
scale: &dyn Fn(&str) -> Option<(f64, String)>,
) -> Ordering
pub fn compare_with( &self, other: &Value, scale: &dyn Fn(&str) -> Option<(f64, String)>, ) -> Ordering
Value::compare with an explicit unit-expression resolver
(the adapter’s unit_scale), so custom-unit text takes its
place on the magnitude line exactly as it does in criteria.