Skip to main content

MiraValue

Enum MiraValue 

Source
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

Source

pub fn array(value: MiraHandle<impl MiraArray>) -> Self

Create a MiraValue representing an array value.

Source

pub const fn is_array(self) -> bool

Check whether this value is an array value.

Source

pub fn as_array(&self) -> Option<MiraHandle<dyn MiraArray>>

Return the array handle, or None for another value type.

Source§

impl MiraValue

Source

pub const fn boolean(value: bool) -> Self

Create a MiraValue representing a boolean value.

Source

pub const fn is_boolean(self) -> bool

Check whether this value is a boolean value.

Source

pub fn as_boolean(&self) -> Option<bool>

Return the inline boolean payload, or None for another value type.

Source§

impl MiraValue

Source

pub fn function(value: MiraHandle<impl MiraFunction>) -> Self

Create a MiraValue representing a callable function.

Source

pub const fn is_function(self) -> bool

Check whether this value is a callable function.

Source

pub fn as_function(&self) -> Option<MiraHandle<dyn MiraFunction>>

Return the function handle, or None for another value type.

Source§

impl MiraValue

Source

pub fn module(value: MiraHandle<impl MiraModule>) -> Self

Create a MiraValue representing a module value.

Source

pub const fn is_module(self) -> bool

Check whether this value is a module value.

Source

pub fn as_module(&self) -> Option<MiraHandle<dyn MiraModule>>

Return the module handle, or None for another value type.

Source§

impl MiraValue

Source

pub const fn nil() -> Self

Return a MiraValue representing the MiraScript nil value.

Source

pub const fn is_nil(self) -> bool

Check whether this value is the MiraScript nil value.

Source§

impl MiraValue

Source

pub const fn number(value: f64) -> Self

Create a MiraValue representing a numeric value.

Source

pub const fn is_number(self) -> bool

Check whether this value is a numeric value.

Source

pub fn as_number(&self) -> Option<f64>

Return the inline numeric payload, or None for another value type.

Source§

impl MiraValue

Source

pub fn record(value: MiraHandle<impl MiraRecord>) -> Self

Create a MiraValue representing a record.

Source

pub const fn is_record(self) -> bool

Check whether this value is a record.

Source

pub fn as_record(&self) -> Option<MiraHandle<dyn MiraRecord>>

Return the record handle, or None for another value type.

Source§

impl MiraValue

Source

pub const fn str(value: &'static &'static str) -> Self

Create a MiraValue representing a static string.

Source

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.

Source

pub const fn is_string(&self) -> bool

Return whether this value is a static or arena-managed string.

Source

pub fn as_str<'s>(&self, runtime: &'s Runtime) -> Result<Option<&'s str>>

Borrow this value’s string payload from its owning Runtime.

Source§

impl MiraValue

Source

pub const fn value_type(self) -> MiraType

Return this value’s MiraScript category.

Source

pub const fn type_name(self) -> &'static str

Return the MiraScript type name for this value.

Trait Implementations§

Source§

impl Clone for MiraValue

Source§

fn clone(&self) -> MiraValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MiraValue

Source§

impl Debug for MiraValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MiraValue

Source§

fn default() -> MiraValue

Returns the “default value” for a type. Read more
Source§

impl From<&'static &'static str> for MiraValue

Source§

fn from(value: &'static &'static str) -> Self

Converts to this type from the input type.
Source§

impl From<MiraValue> for MiraManageable

Source§

fn from(value: MiraValue) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<MiraValue>> From<Option<T>> for MiraValue

Source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for MiraValue

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for MiraValue

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for MiraValue

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for MiraValue

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for MiraValue

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for MiraValue

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for MiraValue

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for MiraValue

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for MiraValue

Source§

fn from(value: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for MiraValue

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for MiraValue

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for MiraValue

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for MiraValue

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for MiraValue

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for MiraValue

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MiraValue

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MiraValue

Source§

impl TryFrom<MiraValue> for bool

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for u8

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for u16

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for u32

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for u64

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for u128

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for usize

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for i8

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for i16

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for i32

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for i64

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for i128

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for isize

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for f64

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<MiraValue> for f32

Source§

type Error = Box<MiraError>

The type returned in the event of a conversion error.
Source§

fn try_from(value: MiraValue) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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