Struct rquickjs_core::Object [−][src]
#[repr(transparent)]pub struct Object<'js>(_);
Expand description
Rust representation of a javascript object.
Implementations
Initialize an object using ObjectDef
Create an object using ObjectDef
check wether the object contains a certain key.
Set a member of an object to a certain value
Get own string enumerable property names of an object
Get own property names of an object
Get own string enumerable properties of an object
Get own properties of an object
Get own string enumerable property values of an object
Get own property values of an object
Get an object prototype
Set an object prototype
Convert into a function
Convert into an array
Convert into value
Convert from value
This is supported on crate feature classes
only.
classes
only.Check the object for instance of
This is supported on crate feature classes
only.
classes
only.Convert object into instance of class
pub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<()> where
K: IntoAtom<'js>,
V: AsProperty<'js, P>,
This is supported on crate feature properties
only.
pub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<()> where
K: IntoAtom<'js>,
V: AsProperty<'js, P>,
properties
only.Define a property of an object
// Define readonly property without value
obj.prop("no_val", ()).unwrap();
// Define readonly property with value
obj.prop("ro_str", "Some const text").unwrap();
// Define readonly property with value and make it to be writable
obj.prop("ro_str2", Property::from("Some const text").writable()).unwrap();
// Define readonly property using getter and make it to be enumerable
obj.prop("ro_str_get", Accessor::from(|| "Some readable text").enumerable()).unwrap();
// Define readonly property using getter and setter
obj.prop("ro_str_get_set",
Accessor::from(|| "Some text")
.set(|new_val: String| { /* do something */ })
).unwrap();
Methods from Deref<Target = Value<'js>>
Check if the value is a function
Try reinterprete as
Trait Implementations
Auto Trait Implementations
impl<'js> !RefUnwindSafe for Object<'js>
impl<'js> UnwindSafe for Object<'js>
Blanket Implementations
Mutably borrows from an owned value. Read more