pub struct JsObject(_);
Expand description
Garbage collected Object
.
Implementations
sourceimpl JsObject
impl JsObject
sourcepub fn borrow(&self) -> Ref<'_, Object>
pub fn borrow(&self) -> Ref<'_, Object>
Immutably borrows the Object
.
The borrow lasts until the returned Ref
exits scope.
Multiple immutable borrows can be taken out at the same time.
Panics
Panics if the object is currently mutably borrowed.
sourcepub fn borrow_mut(&self) -> RefMut<'_, Object, Object>
pub fn borrow_mut(&self) -> RefMut<'_, Object, Object>
Mutably borrows the Object.
The borrow lasts until the returned RefMut
exits scope.
The object cannot be borrowed while this borrow is active.
Panics
Panics if the object is currently borrowed.
sourcepub fn try_borrow(&self) -> StdResult<Ref<'_, Object>, BorrowError>
pub fn try_borrow(&self) -> StdResult<Ref<'_, Object>, BorrowError>
Immutably borrows the Object
, returning an error if the value is currently mutably borrowed.
The borrow lasts until the returned GcCellRef
exits scope.
Multiple immutable borrows can be taken out at the same time.
This is the non-panicking variant of borrow
.
sourcepub fn try_borrow_mut(
&self
) -> StdResult<RefMut<'_, Object, Object>, BorrowMutError>
pub fn try_borrow_mut(
&self
) -> StdResult<RefMut<'_, Object, Object>, BorrowMutError>
Mutably borrows the object, returning an error if the value is currently borrowed.
The borrow lasts until the returned GcCellRefMut
exits scope.
The object be borrowed while this borrow is active.
This is the non-panicking variant of borrow_mut
.
sourcepub fn equals(lhs: &Self, rhs: &Self) -> bool
pub fn equals(lhs: &Self, rhs: &Self) -> bool
Checks if the garbage collected memory is the same.
sourcepub fn is<T>(&self) -> boolwhere
T: NativeObject,
pub fn is<T>(&self) -> boolwhere
T: NativeObject,
Return true
if it is a native object and the native type is T
.
Panics
Panics if the object is currently mutably borrowed.
sourcepub fn downcast_ref<T>(&self) -> Option<Ref<'_, T>>where
T: NativeObject,
pub fn downcast_ref<T>(&self) -> Option<Ref<'_, T>>where
T: NativeObject,
Downcast a reference to the object,
if the object is type native object type T
.
Panics
Panics if the object is currently mutably borrowed.
sourcepub fn downcast_mut<T>(&mut self) -> Option<RefMut<'_, Object, T>>where
T: NativeObject,
pub fn downcast_mut<T>(&mut self) -> Option<RefMut<'_, Object, T>>where
T: NativeObject,
Downcast a mutable reference to the object,
if the object is type native object type T
.
Panics
Panics if the object is currently borrowed.
sourcepub fn prototype_instance(&self) -> JsValue
pub fn prototype_instance(&self) -> JsValue
sourcepub fn set_prototype_instance(&self, prototype: JsValue) -> bool
pub fn set_prototype_instance(&self, prototype: JsValue) -> bool
Set the prototype of the object.
Panics
Panics if the object is currently mutably borrowed or if th prototype is not an object or undefined.
sourcepub fn is_array_iterator(&self) -> bool
pub fn is_array_iterator(&self) -> bool
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
sourcepub fn is_ordinary(&self) -> bool
pub fn is_ordinary(&self) -> bool
sourcepub fn is_native_object(&self) -> bool
pub fn is_native_object(&self) -> bool
Returns true
if it holds an Rust type that implements NativeObject
.
Panics
Panics if the object is currently mutably borrowed.
pub fn to_property_descriptor(
&self,
context: &mut Context
) -> JsResult<PropertyDescriptor>
sourcepub fn copy_data_properties<K>(
&mut self,
source: &JsValue,
excluded_keys: Vec<K>,
context: &mut Context
) -> JsResult<()>where
K: Into<PropertyKey>,
pub fn copy_data_properties<K>(
&mut self,
source: &JsValue,
excluded_keys: Vec<K>,
context: &mut Context
) -> JsResult<()>where
K: Into<PropertyKey>,
sourcepub fn insert_property<K, P>(
&self,
key: K,
property: P
) -> Option<PropertyDescriptor>where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn insert_property<K, P>(
&self,
key: K,
property: P
) -> Option<PropertyDescriptor>where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
Inserts a field in the object properties
without checking if it’s writable.
If a field was already in the object with the same name that a Some
is returned
with that field, otherwise None is returned.
sourcepub fn is_callable(&self) -> bool
pub fn is_callable(&self) -> bool
It determines if Object is a callable function with a [[Call]]
internal method.
More information:
sourcepub fn is_constructable(&self) -> bool
pub fn is_constructable(&self) -> bool
It determines if Object is a function object with a [[Construct]]
internal method.
More information:
sourceimpl JsObject
impl JsObject
sourcepub fn is_extensible(&self, context: &mut Context) -> JsResult<bool>
pub fn is_extensible(&self, context: &mut Context) -> JsResult<bool>
sourcepub fn get<K>(&self, key: K, context: &mut Context) -> JsResult<JsValue>where
K: Into<PropertyKey>,
pub fn get<K>(&self, key: K, context: &mut Context) -> JsResult<JsValue>where
K: Into<PropertyKey>,
sourcepub fn set<K, V>(
&self,
key: K,
value: V,
throw: bool,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn set<K, V>(
&self,
key: K,
value: V,
throw: bool,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
sourcepub fn create_data_property<K, V>(
&self,
key: K,
value: V,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn create_data_property<K, V>(
&self,
key: K,
value: V,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
sourcepub fn create_data_property_or_throw<K, V>(
&self,
key: K,
value: V,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn create_data_property_or_throw<K, V>(
&self,
key: K,
value: V,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
V: Into<JsValue>,
sourcepub fn define_property_or_throw<K, P>(
&self,
key: K,
desc: P,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn define_property_or_throw<K, P>(
&self,
key: K,
desc: P,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
sourcepub fn delete_property_or_throw<K>(
&self,
key: K,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
pub fn delete_property_or_throw<K>(
&self,
key: K,
context: &mut Context
) -> JsResult<bool>where
K: Into<PropertyKey>,
Defines the property or throws a TypeError
if the operation fails.
More information:
sourcepub fn has_property<K>(&self, key: K, context: &mut Context) -> JsResult<bool>where
K: Into<PropertyKey>,
pub fn has_property<K>(&self, key: K, context: &mut Context) -> JsResult<bool>where
K: Into<PropertyKey>,
sourcepub fn has_own_property<K>(&self, key: K, context: &mut Context) -> JsResult<bool>where
K: Into<PropertyKey>,
pub fn has_own_property<K>(&self, key: K, context: &mut Context) -> JsResult<bool>where
K: Into<PropertyKey>,
sourcepub fn call(
&self,
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
pub fn call(
&self,
this: &JsValue,
args: &[JsValue],
context: &mut Context
) -> JsResult<JsValue>
sourcepub fn construct(
&self,
args: &[JsValue],
new_target: &JsValue,
context: &mut Context
) -> JsResult<JsValue>
pub fn construct(
&self,
args: &[JsValue],
new_target: &JsValue,
context: &mut Context
) -> JsResult<JsValue>
Construct an instance of this object with the specified arguments.
Panics
Panics if the object is currently mutably borrowed.