pub enum Value {
Show 19 variants
Int(i64),
Float(f64),
Bool(bool),
Str(String),
Bytes(Vec<u8>),
List(Vec<Value>),
Dict(IndexMap<String, Value>),
Tuple(Vec<Value>),
Option(Option<Box<Value>>),
Result(Result<Box<Value>, Box<Value>>),
Fn(IonFn),
BuiltinFn(String, BuiltinFn),
BuiltinClosure(String, BuiltinClosureFn),
Set(Vec<Value>),
HostStruct {
type_name: String,
fields: IndexMap<String, Value>,
},
HostEnum {
enum_name: String,
variant: String,
data: Vec<Value>,
},
Cell(Arc<Mutex<Value>>),
Range {
start: i64,
end: i64,
inclusive: bool,
},
Unit,
}Expand description
Runtime value representation.
Variants§
Int(i64)
Float(f64)
Bool(bool)
Str(String)
Bytes(Vec<u8>)
List(Vec<Value>)
Dict(IndexMap<String, Value>)
Tuple(Vec<Value>)
Option(Option<Box<Value>>)
Result(Result<Box<Value>, Box<Value>>)
Fn(IonFn)
BuiltinFn(String, BuiltinFn)
BuiltinClosure(String, BuiltinClosureFn)
Closure-backed builtin. Unlike BuiltinFn (a bare fn pointer),
this variant can capture host-side state — e.g. a
tokio::runtime::Handle for async host calls, a database
connection pool, or shared counters.
Register via Engine::register_closure.
Set(Vec<Value>)
Ordered set of unique values
HostStruct
Host-injected struct: TypeName { field: val, ... }
HostEnum
Host-injected enum variant: EnumName::Variant or EnumName::Variant(data)
Cell(Arc<Mutex<Value>>)
Shared mutable reference cell for closure state
Range
Lazy integer range (start..end or start..=end)
Unit
Implementations§
Source§impl Value
impl Value
pub fn type_name(&self) -> &'static str
pub fn is_truthy(&self) -> bool
pub fn as_int(&self) -> Option<i64>
pub fn as_float(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&str>
pub fn as_bool(&self) -> Option<bool>
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more