Skip to main content

Value

Enum Value 

Source
#[repr(C, u8)]
pub enum Value {
Show 16 variants Nil, Bool(bool), Int(LustInt), Float(LustFloat), String(Rc<String>), Array(Rc<RefCell<Vec<Value>>>), Tuple(Rc<Vec<Value>>), Map(Rc<RefCell<LustMap>>), Struct { name: String, layout: Rc<StructLayout>, fields: Rc<RefCell<Vec<Value>>>, }, WeakStruct(WeakStructRef), Enum { enum_name: String, variant: String, values: Option<Rc<Vec<Value>>>, }, Function(usize), NativeFunction(NativeFn), Closure { function_idx: usize, upvalues: Rc<Vec<Upvalue>>, }, Iterator(Rc<RefCell<IteratorState>>), Task(TaskHandle),
}

Variants§

§

Nil

§

Bool(bool)

§

Int(LustInt)

§

Float(LustFloat)

§

String(Rc<String>)

§

Array(Rc<RefCell<Vec<Value>>>)

§

Tuple(Rc<Vec<Value>>)

§

Map(Rc<RefCell<LustMap>>)

§

Struct

Fields

§name: String
§fields: Rc<RefCell<Vec<Value>>>
§

WeakStruct(WeakStructRef)

§

Enum

Fields

§enum_name: String
§variant: String
§values: Option<Rc<Vec<Value>>>
§

Function(usize)

§

NativeFunction(NativeFn)

§

Closure

Fields

§function_idx: usize
§upvalues: Rc<Vec<Upvalue>>
§

Iterator(Rc<RefCell<IteratorState>>)

§

Task(TaskHandle)

Implementations§

Source§

impl Value

Source

pub fn tag(&self) -> ValueTag

Source

pub fn type_of(&self) -> ValueType

Source

pub fn is_truthy(&self) -> bool

Source

pub fn to_bool(&self) -> bool

Source

pub fn as_int(&self) -> Option<LustInt>

Source

pub fn as_float(&self) -> Option<LustFloat>

Source

pub fn as_string(&self) -> Option<&str>

Source

pub fn as_string_rc(&self) -> Option<Rc<String>>

Source

pub fn as_task_handle(&self) -> Option<TaskHandle>

Source

pub fn as_array(&self) -> Option<Vec<Value>>

Source

pub fn array_len(&self) -> Option<usize>

Source

pub fn array_get(&self, index: usize) -> Option<Value>

Source

pub fn array_push(&self, value: Value) -> Result<(), String>

Source

pub fn array_pop(&self) -> Result<Option<Value>, String>

Source

pub fn as_map(&self) -> Option<LustMap>

Source

pub fn map_get(&self, key: &ValueKey) -> Option<Value>

Source

pub fn map_set(&self, key: ValueKey, value: Value) -> Result<(), String>

Source

pub fn map_has(&self, key: &ValueKey) -> Option<bool>

Source

pub fn map_delete(&self, key: &ValueKey) -> Result<Option<Value>, String>

Source

pub fn map_len(&self) -> Option<usize>

Source

pub fn string(s: impl Into<String>) -> Self

Source

pub fn array(values: Vec<Value>) -> Self

Source

pub fn tuple(values: Vec<Value>) -> Self

Source

pub fn tuple_len(&self) -> Option<usize>

Source

pub fn tuple_get(&self, index: usize) -> Option<Value>

Source

pub fn map(entries: LustMap) -> Self

Source

pub fn task(handle: TaskHandle) -> Self

Source

pub fn struct_get_field_rc(&self, field: &Rc<String>) -> Option<Value>

Source

pub fn struct_get_field(&self, field: &str) -> Option<Value>

Source

pub fn struct_get_field_indexed(&self, index: usize) -> Option<Value>

Source

pub fn struct_set_field_rc( &self, field: &Rc<String>, value: Value, ) -> Result<(), String>

Source

pub fn struct_set_field(&self, field: &str, value: Value) -> Result<(), String>

Source

pub fn struct_set_field_indexed( &self, index: usize, value: Value, ) -> Result<(), String>

Source

pub fn enum_unit( enum_name: impl Into<String>, variant: impl Into<String>, ) -> Self

Source

pub fn enum_variant( enum_name: impl Into<String>, variant: impl Into<String>, values: Vec<Value>, ) -> Self

Source

pub fn as_enum(&self) -> Option<(&str, &str, Option<&[Value]>)>

Source

pub fn is_enum_variant(&self, enum_name: &str, variant: &str) -> bool

Source

pub fn some(value: Value) -> Self

Source

pub fn none() -> Self

Source

pub fn ok(value: Value) -> Self

Source

pub fn err(error: Value) -> Self

Source

pub fn to_string(&self) -> String

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate 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 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 From<Value> for NativeCallResult

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for ValueKey

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl FromLustValue for Value

Source§

impl<'a> FromStructField<'a> for Value

Source§

fn from_value(_field: &str, value: ValueRef<'a>) -> Result<Self>

Source§

impl IntoLustValue for Value

Source§

impl IntoTypedValue for Value

Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin 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> FromLustArgs for T
where T: FromLustValue,

Source§

impl<T> FunctionArgs for T
where T: IntoLustValue + 'static,

Source§

fn into_values(self) -> Vec<Value>

Source§

fn validate_signature( function_name: &str, params: &[Type], ) -> Result<(), LustError>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V