#[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
WeakStruct(WeakStructRef)
Enum
Function(usize)
NativeFunction(NativeFn)
Closure
Iterator(Rc<RefCell<IteratorState>>)
Task(TaskHandle)
Implementations§
Source§impl Value
impl Value
pub fn tag(&self) -> ValueTag
pub fn type_of(&self) -> ValueType
pub fn is_truthy(&self) -> bool
pub fn to_bool(&self) -> bool
pub fn as_int(&self) -> Option<LustInt>
pub fn as_float(&self) -> Option<LustFloat>
pub fn as_string(&self) -> Option<&str>
pub fn as_string_rc(&self) -> Option<Rc<String>>
pub fn as_task_handle(&self) -> Option<TaskHandle>
pub fn as_array(&self) -> Option<Vec<Value>>
pub fn array_len(&self) -> Option<usize>
pub fn array_get(&self, index: usize) -> Option<Value>
pub fn array_push(&self, value: Value) -> Result<(), String>
pub fn array_pop(&self) -> Result<Option<Value>, String>
pub fn as_map(&self) -> Option<LustMap>
pub fn map_get(&self, key: &ValueKey) -> Option<Value>
pub fn map_set(&self, key: ValueKey, value: Value) -> Result<(), String>
pub fn map_has(&self, key: &ValueKey) -> Option<bool>
pub fn map_delete(&self, key: &ValueKey) -> Result<Option<Value>, String>
pub fn map_len(&self) -> Option<usize>
pub fn string(s: impl Into<String>) -> Self
pub fn array(values: Vec<Value>) -> Self
pub fn tuple(values: Vec<Value>) -> Self
pub fn tuple_len(&self) -> Option<usize>
pub fn tuple_get(&self, index: usize) -> Option<Value>
pub fn map(entries: LustMap) -> Self
pub fn task(handle: TaskHandle) -> Self
pub fn struct_get_field_rc(&self, field: &Rc<String>) -> Option<Value>
pub fn struct_get_field(&self, field: &str) -> Option<Value>
pub fn struct_get_field_indexed(&self, index: usize) -> Option<Value>
pub fn struct_set_field_rc( &self, field: &Rc<String>, value: Value, ) -> Result<(), String>
pub fn struct_set_field(&self, field: &str, value: Value) -> Result<(), String>
pub fn struct_set_field_indexed( &self, index: usize, value: Value, ) -> Result<(), String>
pub fn enum_unit( enum_name: impl Into<String>, variant: impl Into<String>, ) -> Self
pub fn enum_variant( enum_name: impl Into<String>, variant: impl Into<String>, values: Vec<Value>, ) -> Self
pub fn as_enum(&self) -> Option<(&str, &str, Option<&[Value]>)>
pub fn is_enum_variant(&self, enum_name: &str, variant: &str) -> bool
pub fn some(value: Value) -> Self
pub fn none() -> Self
pub fn ok(value: Value) -> Self
pub fn err(error: Value) -> Self
pub fn to_string(&self) -> String
Trait Implementations§
Source§impl From<Value> for NativeCallResult
impl From<Value> for NativeCallResult
Source§impl FromLustValue for Value
impl FromLustValue for Value
fn from_value(value: Value) -> Result<Self>
fn matches_lust_type(_: &Type) -> bool
fn type_description() -> &'static str
Source§impl<'a> FromStructField<'a> for Value
impl<'a> FromStructField<'a> for Value
Source§impl IntoLustValue for Value
impl IntoLustValue for Value
fn into_value(self) -> Value
fn matches_lust_type(_: &Type) -> bool
fn type_description() -> &'static str
Source§impl IntoTypedValue for Value
impl IntoTypedValue for Value
fn into_typed_value(self) -> TypedValue
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more