Struct rquickjs::Object [−][src]
Rust representation of a javascript object.
Implementations
impl<'js> Object<'js>
[src]
pub fn new(ctx: Ctx<'js>) -> Result<Object<'js>, Error>
[src]
Create a new javascript object
pub fn init_def<T>(&self) -> Result<(), Error> where
T: ObjectDef,
[src]
T: ObjectDef,
Initialize an object using ObjectDef
pub fn new_def<T>(ctx: Ctx<'js>) -> Result<Object<'js>, Error> where
T: ObjectDef,
[src]
T: ObjectDef,
Create an object using ObjectDef
pub fn get<K, V>(&self, k: K) -> Result<V, Error> where
K: IntoAtom<'js>,
V: FromJs<'js>,
[src]
K: IntoAtom<'js>,
V: FromJs<'js>,
Get a new value
pub fn contains_key<K>(&self, k: K) -> Result<bool, Error> where
K: IntoAtom<'js>,
[src]
K: IntoAtom<'js>,
check wether the object contains a certain key.
pub fn set<K, V>(&self, key: K, value: V) -> Result<(), Error> where
K: IntoAtom<'js>,
V: IntoJs<'js>,
[src]
K: IntoAtom<'js>,
V: IntoJs<'js>,
Set a member of an object to a certain value
pub fn remove<K>(&self, key: K) -> Result<(), Error> where
K: IntoAtom<'js>,
[src]
K: IntoAtom<'js>,
Remove a member of an object
pub fn is_empty(&self) -> bool
[src]
Check the object for empty
pub fn len(&self) -> usize
[src]
Get the number of properties
pub fn keys<K>(&self) -> ObjectKeysIter<'js, K> where
K: FromAtom<'js>,
[src]
K: FromAtom<'js>,
Get own string enumerable property names of an object
pub fn own_keys<K>(&self, filter: Filter) -> ObjectKeysIter<'js, K> where
K: FromAtom<'js>,
[src]
K: FromAtom<'js>,
Get own property names of an object
pub fn props<K, V>(&self) -> ObjectIter<'js, K, V> where
K: FromAtom<'js>,
V: FromJs<'js>,
[src]
K: FromAtom<'js>,
V: FromJs<'js>,
Get own string enumerable properties of an object
pub fn own_props<K, V>(&self, filter: Filter) -> ObjectIter<'js, K, V> where
K: FromAtom<'js>,
V: FromJs<'js>,
[src]
K: FromAtom<'js>,
V: FromJs<'js>,
Get own properties of an object
pub fn values<K>(&self) -> ObjectValuesIter<'js, K> where
K: FromAtom<'js>,
[src]
K: FromAtom<'js>,
Get own string enumerable property values of an object
pub fn own_values<K>(&self, filter: Filter) -> ObjectValuesIter<'js, K> where
K: FromAtom<'js>,
[src]
K: FromAtom<'js>,
Get own property values of an object
pub fn get_prototype(&self) -> Result<Object<'js>, Error>
[src]
Get an object prototype
pub fn set_prototype(&self, proto: &Object<'js>) -> Result<(), Error>
[src]
Set an object prototype
pub fn into_function(self) -> Option<Function<'js>>
[src]
Convert into a function
pub fn into_array(self) -> Option<Array<'js>>
[src]
Convert into an array
impl<'js> Object<'js>
[src]
pub fn instance_of<C>(&self) -> bool where
C: ClassDef,
[src]
C: ClassDef,
classes
only.Check the object for instance of
pub fn into_instance<C>(self) -> Option<Class<'js, C>> where
C: ClassDef,
[src]
C: ClassDef,
classes
only.Convert object into instance of class
impl<'js> Object<'js>
[src]
pub fn prop<K, V, P>(&self, key: K, prop: V) -> Result<(), Error> where
K: IntoAtom<'js>,
V: AsProperty<'js, P>,
[src]
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();
impl<'js> Object<'js>
[src]
pub fn as_value(&self) -> &Value<'js>
[src]
Reference to value
pub fn into_value(self) -> Value<'js>
[src]
Convert into value
pub fn from_value(value: Value<'js>) -> Result<Object<'js>, Error>
[src]
Convert from value
Methods from Deref<Target = Value<'js>>
pub fn as_bool(&self) -> Option<bool>
[src]
Try get bool from value
pub fn as_int(&self) -> Option<i32>
[src]
Try get int from value
pub fn as_float(&self) -> Option<f64>
[src]
Try get float from value
pub fn as_number(&self) -> Option<f64>
[src]
Try get any number from value
pub fn is_bool(&self) -> bool
[src]
Check if the value is a bool
pub fn is_int(&self) -> bool
[src]
Check if the value is an int
pub fn is_float(&self) -> bool
[src]
Check if the value is a float
pub fn is_number(&self) -> bool
[src]
Check if the value is an any number
pub fn is_string(&self) -> bool
[src]
Check if the value is a string
pub fn is_symbol(&self) -> bool
[src]
Check if the value is a symbol
pub fn is_object(&self) -> bool
[src]
Check if the value is an object
pub fn is_module(&self) -> bool
[src]
Check if the value is a module
pub fn is_array(&self) -> bool
[src]
Check if the value is an array
pub fn is_function(&self) -> bool
[src]
Check if the value is a function
pub fn is_error(&self) -> bool
[src]
Check if the value is an error
pub fn as_value(&self) -> &Value<'js>
[src]
Reference as value
pub fn get<T>(&self) -> Result<T, Error> where
T: FromJs<'js>,
[src]
T: FromJs<'js>,
Convert from value to specified type
pub fn type_of(&self) -> Type
[src]
Get the type of value
pub fn type_name(&self) -> &'static str
[src]
Get the name of type
pub unsafe fn ref_string(&self) -> &String<'js>
[src]
pub fn as_string(&self) -> Option<&String<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
[src]
pub fn as_symbol(&self) -> Option<&Symbol<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_object(&self) -> &Object<'js>
[src]
pub fn as_object(&self) -> Option<&Object<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_array(&self) -> &Array<'js>
[src]
pub fn as_array(&self) -> Option<&Array<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_function(&self) -> &Function<'js>
[src]
pub fn as_function(&self) -> Option<&Function<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_module(&self) -> &Module<'js, Evaluated>
[src]
pub fn as_module(&self) -> Option<&Module<'js, Evaluated>>
[src]
Try reinterprete as
Trait Implementations
impl<'js, C> AsRef<Object<'js>> for Class<'js, C>
[src]
impl<'js> AsRef<Value<'js>> for Object<'js>
[src]
impl<'js> Clone for Object<'js>
[src]
impl<'js> Debug for Object<'js>
[src]
impl<'js> Deref for Object<'js>
[src]
type Target = Value<'js>
The resulting type after dereferencing.
pub fn deref(&self) -> &<Object<'js> as Deref>::Target
[src]
impl<'js> From<Object<'js>> for Value<'js>
[src]
impl<'js, K, V> FromIteratorJs<'js, (K, V)> for Object<'js> where
K: IntoAtom<'js>,
V: IntoJs<'js>,
[src]
K: IntoAtom<'js>,
V: IntoJs<'js>,
type Item = (Atom<'js>, Value<'js>)
pub fn from_iter_js<T>(ctx: Ctx<'js>, iter: T) -> Result<Object<'js>, Error> where
T: IntoIterator<Item = (K, V)>,
[src]
T: IntoIterator<Item = (K, V)>,
impl<'js> FromJs<'js> for Object<'js>
[src]
impl<'js> IntoAtom<'js> for Object<'js>
[src]
impl<'js> IntoIterator for Object<'js>
[src]
type Item = Result<(Atom<'js>, Value<'js>), Error>
The type of the elements being iterated over.
type IntoIter = ObjectIter<'js, Atom<'js>, Value<'js>>
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> <Object<'js> as IntoIterator>::IntoIter
[src]
impl<'js> IntoJs<'js> for Object<'js>
[src]
impl<'js, 't> Outlive<'t> for Object<'js>
[src]
impl<'js> PartialEq<Object<'js>> for Object<'js>
[src]
pub fn eq(&self, other: &Object<'js>) -> bool
[src]
pub fn ne(&self, other: &Object<'js>) -> bool
[src]
impl<'js> StructuralPartialEq for Object<'js>
[src]
Auto Trait Implementations
impl<'js> !RefUnwindSafe for Object<'js>
[src]
impl<'js> !Send for Object<'js>
[src]
impl<'js> !Sync for Object<'js>
[src]
impl<'js> Unpin for Object<'js>
[src]
impl<'js> UnwindSafe for Object<'js>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<'js, T> AsProperty<'js, T> for T where
T: IntoJs<'js>,
[src]
T: IntoJs<'js>,
pub fn config(
self,
ctx: Ctx<'js>
) -> Result<(i32, Value<'js>, Value<'js>, Value<'js>), Error>
[src]
self,
ctx: Ctx<'js>
) -> Result<(i32, Value<'js>, Value<'js>, Value<'js>), Error>
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ParallelSend for T where
T: Send,
[src]
T: Send,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,