pub struct MiraValue(/* private fields */);Expand description
A compact value understood by the Rust VM.
Numbers are stored inline as f64. Other values use checked tags and a
48-bit payload in a NaN-box. Runtime-owned payloads remain checked handles
into a crate::Runtime arena.
Implementations§
Source§impl MiraValue
impl MiraValue
Sourcepub const fn array<T: MiraArray + ?Sized>(value: MiraHandle<T>) -> Self
pub const fn array<T: MiraArray + ?Sized>(value: MiraHandle<T>) -> Self
Create a MiraValue representing an array value.
Sourcepub fn as_array(&self) -> Option<MiraArrayHandle>
pub fn as_array(&self) -> Option<MiraArrayHandle>
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 const fn as_boolean(&self) -> Option<bool>
pub const fn as_boolean(&self) -> Option<bool>
Return the inline boolean payload, or None for another value type.
Sourcepub const fn as_boolean_unchecked(self) -> bool
pub const fn as_boolean_unchecked(self) -> bool
Return the inline boolean payload.
Source§impl MiraValue
impl MiraValue
Sourcepub const fn function<T: MiraFunction + ?Sized>(value: MiraHandle<T>) -> Self
pub const fn function<T: MiraFunction + ?Sized>(value: MiraHandle<T>) -> 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<MiraFunctionHandle>
pub fn as_function(&self) -> Option<MiraFunctionHandle>
Return the function handle, or None for another value type.
Source§impl MiraValue
impl MiraValue
Sourcepub const fn module<T: MiraModule + ?Sized>(value: MiraHandle<T>) -> Self
pub const fn module<T: MiraModule + ?Sized>(value: MiraHandle<T>) -> 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
Source§impl MiraValue
impl MiraValue
Sourcepub const fn record<T: MiraRecord + ?Sized>(value: MiraHandle<T>) -> Self
pub const fn record<T: MiraRecord + ?Sized>(value: MiraHandle<T>) -> 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 fn str(value: &'static &'static str) -> Self
pub fn str(value: &'static &'static str) -> Self
Create a MiraValue representing a static string.
Sourcepub const fn string(value: MiraHandle<String>) -> Self
pub const fn string(value: MiraHandle<String>) -> Self
Create a MiraValue representing a string value.
Sourcepub fn as_str<'s>(&self, runtime: &'s Runtime) -> Result<Option<&'s str>>
pub fn as_str<'s>(&self, runtime: &'s Runtime) -> Result<Option<&'s str>>
Borrow this value’s string payload from its owning Runtime.
Sourcepub fn as_str_unchecked<'s>(&self, runtime: &'s Runtime) -> &'s str
pub fn as_str_unchecked<'s>(&self, runtime: &'s Runtime) -> &'s str
Borrow this value’s string payload from its owning Runtime.