pub enum ValueData {
Null,
Undefined,
Boolean(bool),
String(String),
Number(f64),
Integer(i32),
Object(GcCell<ObjectData>),
Function(GcCell<Function>),
}
Expand description
A Javascript value
Variants
Null
null
- A null value, for when a value doesn’t exist
Undefined
undefined
- An undefined value, for when a field or index doesn’t exist
Boolean(bool)
boolean
- A true
/ false
value, for if a certain criteria is met
String(String)
String
- A UTF-8 string, such as "Hello, world"
Number(f64)
Number
- A 64-bit floating point number, such as 3.1415
Integer(i32)
Number
- A 32-bit integer, such as 42
Object(GcCell<ObjectData>)
Object
- An object, such as Math
, represented by a binary tree of string keys to Javascript values
Function(GcCell<Function>)
Function
- A runnable block of code, such as Math.sqrt
, which can take some variables and return a useful value or act upon an object
Implementations
sourceimpl ValueData
impl ValueData
sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Returns true if the value is undefined
sourcepub fn is_null_or_undefined(&self) -> bool
pub fn is_null_or_undefined(&self) -> bool
Returns true if the value is null or undefined
sourcepub fn get_prop(&self, field: String) -> Option<Property>
pub fn get_prop(&self, field: String) -> Option<Property>
Resolve the property in the object Returns a copy of the Property
sourcepub fn get_field(&self, field: String) -> Value
pub fn get_field(&self, field: String) -> Value
Resolve the property in the object and get its value, or undefined if this is not an object or the field doesn’t exist
sourcepub fn get_field_slice<'a>(&self, field: &'a str) -> Value
pub fn get_field_slice<'a>(&self, field: &'a str) -> Value
Resolve the property in the object and get its value, or undefined if this is not an object or the field doesn’t exist
sourcepub fn set_field_slice<'a>(&self, field: &'a str, val: Value) -> Value
pub fn set_field_slice<'a>(&self, field: &'a str, val: Value) -> Value
Set the field in the value
sourcepub fn set_prop(&self, field: String, prop: Property) -> Property
pub fn set_prop(&self, field: String, prop: Property) -> Property
Set the property in the value
sourcepub fn set_prop_slice<'t>(&self, field: &'t str, prop: Property) -> Property
pub fn set_prop_slice<'t>(&self, field: &'t str, prop: Property) -> Property
Set the property in the value