pub enum Value {
Null,
Bool(bool),
Int(i64),
UInt(u64),
Float(f64),
Str(Arc<str>),
List(Arc<[Value]>),
Map(Arc<Map>),
Function(Arc<NativeFunction>),
}Expand description
One expression value.
Values are immutable and cheap to clone: strings, lists, maps and functions
are behind an Arc.
PartialEq is the expression language’s == (see Value::equals), so a
host comparing values in Rust compares them the way the workflow does.
Variants§
Null
Bool(bool)
Int(i64)
A 64-bit integer: what an integer literal is, and what +, -, *,
/ and % stay in while both operands are ints.
UInt(u64)
An integer above i64::MAX — what JSON gives a host for one, since a
JSON integer is an i64 or a u64 and nothing else represents
u64::MAX exactly. A value this wide is never produced from a literal
and only ever shows up injected; arithmetic that mixes it with an int
is exact.
Float(f64)
A 64-bit float. Mixed int/float arithmetic produces a float.
Str(Arc<str>)
List(Arc<[Value]>)
Map(Arc<Map>)
An injected object. a.b reads a member, a['b'] the same key.
Function(Arc<NativeFunction>)
An injected method. f(x) calls it directly, a.f(x) calls it with
a as its first argument, and a function stored in a map is called
the same way when reached through that map.
Implementations§
Source§impl Value
impl Value
Sourcepub fn function<F>(f: F) -> Value
pub fn function<F>(f: F) -> Value
Wrap a closure as an injectable method.
use acts_expr::Value;
let upper = Value::function(|args| match args {
[Value::Str(s)] => Ok(Value::from(s.to_uppercase())),
_ => Err(acts_expr::Error::Type { operation: "upper", got: "other" }),
});Sourcepub fn map<K, V, I>(entries: I) -> Value
pub fn map<K, V, I>(entries: I) -> Value
Build an object from key/value pairs.
use acts_expr::Value;
let step = Value::map([("id", Value::from("step1")), ("retries", Value::from(2))]);pub fn is_null(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn as_int(&self) -> Option<i64>
Sourcepub fn as_i128(&self) -> Option<i128>
pub fn as_i128(&self) -> Option<i128>
The value as a 128-bit integer: exact for both integer kinds, which is
what lets int and uint mix without a rounding step.