pub enum MiraValue {
Nil,
Boolean(bool),
Number(f64),
StaticStr(&'static &'static str),
String(MiraHandle<String>),
Array(MiraHandle<dyn MiraArray>),
Record(MiraHandle<dyn MiraRecord>),
Function(MiraHandle<dyn MiraFunction>),
Module(MiraHandle<dyn MiraModule>),
// some variants omitted
}Expand description
A compact value understood by the Rust VM.
Scalar payloads are stored inline. Runtime-owned payloads are represented by
checked handles into a crate::Runtime arena.
Variants§
Nil
The MiraScript nil value.
Boolean(bool)
A boolean value.
Number(f64)
A double-precision numeric value.
StaticStr(&'static &'static str)
A compile-time static UTF-8 string stored as a thin pointer.
String(MiraHandle<String>)
A runtime-owned UTF-8 string.
Array(MiraHandle<dyn MiraArray>)
A MiraScript array.
Record(MiraHandle<dyn MiraRecord>)
A MiraScript record.
Function(MiraHandle<dyn MiraFunction>)
A MiraScript function.
Module(MiraHandle<dyn MiraModule>)
A MiraScript module.
Implementations§
Source§impl MiraValue
impl MiraValue
Sourcepub fn array(value: MiraHandle<impl MiraArray>) -> Self
pub fn array(value: MiraHandle<impl MiraArray>) -> Self
Create a MiraValue representing an array value.
Sourcepub fn as_array(&self) -> Option<MiraHandle<dyn MiraArray>>
pub fn as_array(&self) -> Option<MiraHandle<dyn MiraArray>>
Return the array handle, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub const fn is_boolean(self) -> bool
pub const fn is_boolean(self) -> bool
Check whether this value is a boolean value.
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Return the inline boolean payload, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub fn function(value: MiraHandle<impl MiraFunction>) -> Self
pub fn function(value: MiraHandle<impl MiraFunction>) -> Self
Create a MiraValue representing a callable function.
Sourcepub const fn is_function(self) -> bool
pub const fn is_function(self) -> bool
Check whether this value is a callable function.
Sourcepub fn as_function(&self) -> Option<MiraHandle<dyn MiraFunction>>
pub fn as_function(&self) -> Option<MiraHandle<dyn MiraFunction>>
Return the function handle, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub fn module(value: MiraHandle<impl MiraModule>) -> Self
pub fn module(value: MiraHandle<impl MiraModule>) -> Self
Create a MiraValue representing a module value.
Sourcepub fn as_module(&self) -> Option<MiraHandle<dyn MiraModule>>
pub fn as_module(&self) -> Option<MiraHandle<dyn MiraModule>>
Return the module handle, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub fn record(value: MiraHandle<impl MiraRecord>) -> Self
pub fn record(value: MiraHandle<impl MiraRecord>) -> Self
Create a MiraValue representing a record.
Sourcepub fn as_record(&self) -> Option<MiraHandle<dyn MiraRecord>>
pub fn as_record(&self) -> Option<MiraHandle<dyn MiraRecord>>
Return the record handle, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub const fn str(value: &'static &'static str) -> Self
pub const fn str(value: &'static &'static str) -> Self
Create a MiraValue representing a static string.
Sourcepub fn new_string(
value: impl Into<String>,
runtime: &mut Runtime,
) -> Result<Self>
pub fn new_string( value: impl Into<String>, runtime: &mut Runtime, ) -> Result<Self>
Allocate an owned string in a Runtime and return its value handle.