Value

Enum Value 

Source
pub enum Value {
    Empty,
    Errata(Errata),
    Literal(Literal),
    Array(Arc<Vec<Arc<Value>>>),
    Collection(Arc<HashMap<Arc<str>, Arc<Expression>>>),
    Branch(Arc<str>),
    Closure(Arc<Closure>),
    Eval(Eval),
    Format(Format),
    Instance(Instance),
    Node(Node),
}
Expand description

Unified runtime value used by AIMX evaluation.

Value represents evaluated data flowing through the engine: literals, arrays, collections, closures, workflow/inference types, branches, and Errata. Helper methods provide type inspection, conversions following AIMX rules, and formatting.

Variants§

§

Empty

§

Errata(Errata)

§

Literal(Literal)

§

Array(Arc<Vec<Arc<Value>>>)

§

Collection(Arc<HashMap<Arc<str>, Arc<Expression>>>)

§

Branch(Arc<str>)

§

Closure(Arc<Closure>)

§

Eval(Eval)

§

Format(Format)

§

Instance(Instance)

§

Node(Node)

Implementations§

Source§

impl Value

Source

pub fn convert(input: Arc<str>) -> Arc<Self>

Source

pub fn empty() -> Arc<Self>

Source

pub fn empty_str() -> Arc<str>

Source

pub fn from_number(number: f64) -> Value

Convenience constructor for a numeric Value.

Source

pub fn from_arc_str(text: Arc<str>) -> Self

Convenience constructor for a text Value.

Source

pub fn is_of_type(&self, typedef: &Typedef) -> bool

Return true if this value conforms to the given Typedef.

Source

pub fn is_actual_type(&self, typedef: &Typedef) -> bool

Return true if this value’s structure matches typedef, including nested arrays.

Source

pub fn get_type(&self) -> Result<Typedef>

Get the type of this value.

§Returns

Returns a Result<Typedef> containing the type of this value, or an error if this is an Empty value.

Source

pub fn as_type(self: Arc<Value>, value: Arc<Value>) -> Result<Arc<Value>>

Convert this value to match the type of value (based on its literal variant).

Source

pub fn to_type(self: Arc<Value>, typedef: &Typedef) -> Result<Arc<Value>>

Convert this value to a specific Typedef using AIMX promotion rules.

Source

pub fn is_empty(&self) -> bool

Check if this value is empty.

Returns true if this value is the Empty variant, false otherwise.

Source

pub fn is_error(&self) -> bool

Check if this value contains an error.

Returns true if this value represents an error condition, false otherwise.

Source

pub fn is_literal(&self) -> bool

Check if this value is a literal.

Returns true if this value is the Literal variant, false otherwise. This includes all scalar types: booleans, numbers, text, dates, and tasks.

Source

pub fn is_constant(&self) -> bool

Check if this value is constant (immutable).

Returns true if this value represents a constant value that cannot be modified during evaluation, false otherwise.

Source

pub fn to_literal(self: Arc<Value>) -> Literal

Get a reference to the literal representation of this value.

Returns a reference to a Literal representing this value’s type and content:

  • For literal values, returns a reference to the embedded literal
  • For arrays, returns the literal representation of the last element or Literal::Empty for empty arrays
  • For all other value types, returns Literal::Empty

This method is useful for type checking and introspection, as it provides access to the underlying literal type without consuming the value.

Source

pub fn as_literal(self: Arc<Value>) -> Arc<Value>

Convert this value to its literal representation.

This method consumes the value and returns the underlying literal representation:

  • For literal values, returns the literal itself
  • For arrays, returns the last element or Value::Empty for empty arrays
  • For all other value types, returns Value::Empty
Source

pub fn is_array(&self) -> bool

Check if this value is an array.

Returns true if this value is the Array variant, false otherwise.

Source

pub fn as_array(self: Arc<Value>) -> Arc<Value>

Source

pub fn is_bool(&self) -> bool

Check if this value represents a boolean.

Returns true if this value is a literal boolean, false otherwise.

Source

pub fn as_bool(self: Arc<Value>) -> Arc<Value>

Convert this value to a boolean representation.

Performs type conversion to boolean according to the AIMX grammar’s truthiness rules:

  • Empty values: Always false
  • Numbers: 0 is false, non-zero is true
  • Text: Empty string is false, non-empty is true
  • Dates: Always true (they exist)
  • Arrays: Empty array is false, non-empty is true
  • Tasks: Status determines value, no status is false
Source

pub fn to_bool(self: Arc<Value>) -> Arc<Value>

Source

pub fn is_date(&self) -> bool

Check if this value represents a date.

Returns true if this value is a literal date, false otherwise.

Source

pub fn as_date(self: Arc<Value>) -> Result<Arc<Value>>

Convert this value to a date representation.

Attempts to convert the value to a date according to the AIMX grammar’s conversion rules:

  • Empty values: Remain empty (no conversion needed)
  • Dates: No conversion needed
  • Text: Parsed as date if possible (e.g., “2023-01-01”)
  • Number: Interpreted as Unix timestamp
  • Boolean: true becomes Unix epoch + 1 second, false becomes Unix epoch
  • Task: Text component parsed as date if possible
§Returns

Returns a Result<Value> containing the converted date value or an error if conversion is not possible.

Source

pub fn is_number(&self) -> bool

Check if this value represents a number.

Returns true if this value is a literal number, false otherwise.

Source

pub fn as_number(self: Arc<Value>) -> Result<Arc<Value>>

Convert this value to a number representation.

Attempts to convert the value to a number according to the AIMX grammar’s conversion rules:

  • Empty values: Remain empty (no conversion needed)
  • Numbers: No conversion needed
  • Text: Parsed as number if it represents a valid numeric literal (e.g., “42”, “3.14”)
  • Boolean: false becomes 0, true becomes 1
  • Date: Converted to Unix timestamp
  • Task: Status determines value (true=1, false=-1, none=0)
§Returns

Returns a Result<Value> containing the converted number value or an error if conversion is not possible.

Source

pub fn to_number(&self) -> Result<f64>

Extract a numeric value from this value.

This is a convenience method for when you specifically need a f64 number. It’s particularly useful for arithmetic operations and mathematical functions.

§Returns

Returns a Result<f64> containing the numeric value or an error if:

  • The value is empty
  • The value is an array with no elements
  • The underlying literal cannot be converted to a number
Source

pub fn is_task(&self) -> bool

Check if this value represents a task.

Returns true if this value is a literal task, false otherwise.

Source

pub fn as_task(self: Arc<Value>) -> Result<Arc<Value>>

Convert this value to a task representation.

Attempts to convert the value to a task according to the AIMX grammar’s conversion rules:

  • Empty values: Remain empty (no conversion needed)
  • Tasks: No conversion needed
  • Boolean: Status becomes the boolean value, text becomes “true”/“false”
  • Date: No status, text becomes date string
  • Number: Status based on sign (positive=true, negative=false, zero=none), text becomes number string
  • Text: No status, text remains the same
§Returns

Returns a Result<Value> containing the converted task value or an error if conversion is not possible.

Source

pub fn is_text(&self) -> bool

Check if this value represents text.

Returns true if this value is a literal text, false otherwise.

Source

pub fn as_text(self: Arc<Value>) -> Result<Arc<Value>>

Convert this value to a text representation.

Converts the value to text according to the AIMX grammar’s conversion rules:

  • Empty values: Remain empty (no conversion needed)
  • Text: No conversion needed
  • Boolean: “true” or “false”
  • Date: Formatted as ISO 8601 date string (e.g., “2023-01-01T00:00:00.000”)
  • Number: Formatted as string (e.g., “42”, “3.14”)
  • Task: Text component of the task (status is preserved in the Value but not in the text conversion)
§Returns

Returns a Result<Value> containing the converted text value or an error if conversion is not possible.

Source

pub fn to_arc_str(&self) -> Arc<str>

Source

pub fn is_closure(&self) -> bool

Check if this value represents a closure.

Returns true if this value is a closure, false otherwise.

Source

pub fn is_branch(&self) -> bool

Check if this value represents a branch.

Returns true if this value is a branch, false otherwise.

Source

pub fn is_eval(&self) -> bool

Check if this value represents an eval.

Returns true if this value is an eval, false otherwise.

Source

pub fn to_pass(&self) -> Result<Value>

Source

pub fn to_fail(&self) -> Result<Value>

Source

pub fn is_format(&self) -> bool

Check if this value represents a format.

Returns true if this value is a format, false otherwise.

Source

pub fn is_instance(&self) -> bool

Check if this value represents an instance.

Returns true if this value is an instance, false otherwise.

Source

pub fn get_instance(&self) -> Option<Instance>

Source

pub fn is_node(&self) -> bool

Check if this value represents a node.

Returns true if this value is a node, false otherwise.

Source

pub fn get_node(&self) -> Option<Node>

Source

pub fn as_collection_arc( &self, ) -> Option<Arc<HashMap<Arc<str>, Arc<Expression>>>>

Get Arc-wrapped collection if this is a collection value.

Returns an Arc<HashMap<String, Arc<Expression>>> if this is a collection, allowing cheap cloning and shared access.

Source

pub fn get_collection_ref( &self, ) -> Option<&Arc<HashMap<Arc<str>, Arc<Expression>>>>

Get Arc-wrapped collection reference if this is a collection value.

Returns a reference to the internal Arc<HashMap<String, Arc<Expression>>> without cloning, for direct access when you need to avoid ownership transfer.

Source

pub fn type_as_string(&self) -> &'static str

Get a string representation of this value’s type. Used to provide type information in error messages.

Returns a string indicating the type of this value based on its underlying literal representation. Possible return values are: “Empty”, “Error”, “Bool”, “Date”, “Number”, “Task”, “Text”, “Closure”, “Node”.

Source

pub fn print(&self, writer: &mut Writer)

Write this value to the provided writer using the appropriate formatting.

This implementation delegates to the writer’s print_value method, which handles the formatting based on the writer’s mode (string, sanitized, formula).

§Arguments
  • writer - The writer to write to
Source

pub fn pretty_print(&self, prefix: &Prefix, writer: &mut Writer)

Print this this value using the given Prefix.

Source

pub fn to_pretty_str(&self, prefix: Prefix) -> Arc<str>

Format this value to a pretty string using the given Prefix.

Source

pub fn to_formula(&self) -> String

Return the formula-string representation (round-trippable by the parser).

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · 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<Arc<str>> for Value

Source§

fn from(s: Arc<str>) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime> for Value

Source§

fn from(d: DateTime) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Arc<str>>> for Value

Source§

fn from(array: Vec<Arc<str>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<DateTime>> for Value

Source§

fn from(array: Vec<DateTime>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<bool>> for Value

Source§

fn from(array: Vec<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f64>> for Value

Source§

fn from(array: Vec<f64>) -> 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<f64> for Value

Source§

fn from(n: f64) -> Self

Converts to this type from the input type.
Source§

impl Ord for Value

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl WriterLike for Value

Source§

fn write(&self, writer: &mut Writer)

Serialize this expression with the given Writer.
Source§

fn to_stringized(&self) -> String

Return a string representation (raw unsafe output).
Source§

fn to_sanitized(&self) -> String

Return a sanitized string representation (escaped for safe output).
Source§

fn to_expressionized(&self) -> String

Return a sanitized string representation (escaped for safe output).
Source§

impl Eq for Value

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 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
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,