Skip to main content

Value

Enum Value 

Source
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.

Fields

§secs: i64
§nanos: u32
§offset_min: Option<i16>
§

Duration

A span of time (instant minus instant; the days(n) family). Displays as an ISO-8601 duration (P1DT2H).

Fields

§secs: i64
§nanos: u32
§

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.

Fields

§value: f64
§base: String
§written: Option<(f64, String)>

The authored magnitude and unit, for display (42 km); absent for computed quantities, which display in the base.

Implementations§

Source§

impl Value

Source

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.)

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for Value

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(n: i64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.