Skip to main content

MiraValue

Struct MiraValue 

Source
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

Source

pub const fn array<T: MiraArray + ?Sized>(value: MiraHandle<T>) -> 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<MiraArrayHandle>

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

Source§

impl MiraValue

Source

pub const TRUE: MiraValue

A MiraValue representing the boolean value true.

Source

pub const FALSE: MiraValue

A MiraValue representing the boolean value false.

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 const fn as_boolean(&self) -> Option<bool>

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

Source

pub const fn as_boolean_unchecked(self) -> bool

Return the inline boolean payload.

Source§

impl MiraValue

Source

pub const fn function<T: MiraFunction + ?Sized>(value: MiraHandle<T>) -> 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<MiraFunctionHandle>

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

Source§

impl MiraValue

Source

pub const fn module<T: MiraModule + ?Sized>(value: MiraHandle<T>) -> 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 NIL: MiraValue

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 ZERO: MiraValue

A MiraValue representing the numeric value 0.0.

Source

pub const ONE: MiraValue

A MiraValue representing the numeric value 1.0.

Source

pub const NEGATIVE_ONE: MiraValue

A MiraValue representing the numeric value -1.0.

Source

pub const NAN: MiraValue

A MiraValue representing the numeric value f64::NAN.

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 const fn as_number(&self) -> Option<f64>

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

Source

pub const fn as_number_unchecked(self) -> f64

Return the inline numeric payload.

Source§

impl MiraValue

Source

pub const fn record<T: MiraRecord + ?Sized>(value: MiraHandle<T>) -> 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 fn str(value: &'static &'static str) -> Self

Create a MiraValue representing a static string.

Source

pub const fn string(value: MiraHandle<String>) -> Self

Create a MiraValue representing a string value.

Source

pub 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

pub fn as_str_unchecked<'s>(&self, runtime: &'s Runtime) -> &'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 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) -> Self

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, formatter: &mut Formatter<'_>) -> Result

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

impl Default for MiraValue

Source§

fn default() -> Self

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

impl Default for &MiraValue

Source§

fn default() -> Self

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<MiraHandle<String>> for MiraValue

Source§

fn from(value: MiraHandle<String>) -> Self

Converts to this type from the input type.
Source§

impl From<MiraHandle<dyn MiraArray>> for MiraValue

Source§

fn from(value: MiraHandle<dyn MiraArray>) -> Self

Converts to this type from the input type.
Source§

impl From<MiraHandle<dyn MiraFunction>> for MiraValue

Source§

fn from(value: MiraHandle<dyn MiraFunction>) -> Self

Converts to this type from the input type.
Source§

impl From<MiraHandle<dyn MiraModule>> for MiraValue

Source§

fn from(value: MiraHandle<dyn MiraModule>) -> Self

Converts to this type from the input type.
Source§

impl From<MiraHandle<dyn MiraRecord>> for MiraValue

Source§

fn from(value: MiraHandle<dyn MiraRecord>) -> 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: &Self) -> bool

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

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

Inequality operator !=. Read more
Source§

impl TryFrom<MiraManageable> for MiraValue

Source§

type Error = ()

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

fn try_from(value: MiraManageable) -> Result<Self, Self::Error>

Performs the conversion.
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.
Source§

impl TryFromMira<'_> for MiraValue

Source§

fn from_mira(_runtime: &Runtime, value: MiraValue) -> Result<Self>

Convert a MiraValue into a Rust type, returning an error if the conversion fails.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.