Enum Value

Source
pub enum Value {
    I32(i32),
    I64(i64),
    U32(u32),
    U64(u64),
    String(Box<String>),
    F64(f64),
    Function(Box<Function>),
    NativeFunction(Box<NativeFunction>),
    F32(f32),
    Boolean(bool),
    Unit(()),
}
Expand description

Values that can be stored in the bytecode and manipulated by the VM

Variants§

§

I32(i32)

32-bit signed integer

§

I64(i64)

64-bit signed integer

§

U32(u32)

32-bit unsigned integer

§

U64(u64)

64-bit unsigned integer

§

String(Box<String>)

String value

§

F64(f64)

64-bit floating point

§

Function(Box<Function>)

Function value

§

NativeFunction(Box<NativeFunction>)

Native function value

§

F32(f32)

32-bit floating point

§

Boolean(bool)

Boolean value

§

Unit(())

Unit value (similar to Rust’s ())

Implementations§

Source§

impl Value

Source

pub fn type_tag(&self) -> u8

Returns a tag byte identifying this value’s type

Source

pub fn deserialize_from_type_tag( type_tag: u8, reader: &mut dyn Read, ) -> Result<Self>

Deserialize a value from a reader based on its type tag

§Arguments
  • type_tag - The type tag of the value
  • reader - The reader to read the value data from
§Returns

The deserialized value or an IO error

Source§

impl Value

Source

pub fn is_numeric(&self) -> bool

Check if the value is numeric (integer or float)

Source

pub fn is_integer(&self) -> bool

Check if the value is an integer type

Source

pub fn is_float(&self) -> bool

Check if the value is a float type

Source

pub fn is_signed_integer(&self) -> bool

Check if the value is a signed integer

Source

pub fn is_unsigned_integer(&self) -> bool

Check if the value is an unsigned integer

Source

pub fn is_string(&self) -> bool

Check if the value is a string

Source

pub fn is_boolean(&self) -> bool

Check if the value is a boolean

Trait Implementations§

Source§

impl ArithmeticOps for Value

Source§

fn add(&self, other: &Self) -> Result<Value, String>

Adds two values and returns the result. Read more
Source§

fn subtract(&self, other: &Self) -> Result<Value, String>

Subtracts one value from another and returns the result. Read more
Source§

fn multiply(&self, other: &Self) -> Result<Value, String>

Multiplies two values and returns the result. Read more
Source§

fn divide(&self, other: &Self) -> Result<Value, String>

Divides one value by another and returns the result. Read more
Source§

fn negate(&self) -> Result<Value, String>

Negates a value and returns the result. Read more
Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ComparisonOps for Value

Source§

fn equal(&self, other: &Self) -> Result<Value, String>

Tests if two values are equal. Read more
Source§

fn not_equal(&self, other: &Self) -> Result<Value, String>

Tests if two values are not equal. Read more
Source§

fn less_than(&self, other: &Self) -> Result<Value, String>

Tests if one value is less than another. Read more
Source§

fn less_than_equal(&self, other: &Self) -> Result<Value, String>

Tests if one value is less than or equal to another. Read more
Source§

fn greater_than(&self, other: &Self) -> Result<Value, String>

Tests if one value is greater than another. Read more
Source§

fn greater_than_equal(&self, other: &Self) -> Result<Value, String>

Tests if one value is greater than or equal to another. Read more
Source§

impl Debug for Value

Source§

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

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

impl Display for Value

Source§

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

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

impl LogicalOps for Value

Source§

fn not(&self) -> Result<Value, String>

Performs logical NOT on a boolean value. Read more
Source§

fn and(&self, other: &Self) -> Result<Value, String>

Performs logical AND between two boolean values. Read more
Source§

fn or(&self, other: &Self) -> Result<Value, String>

Performs logical OR between two boolean values. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> ValueOperation for T