Struct JsObject

Source
pub struct JsObject(/* private fields */);
Expand description

Garbage collected Object.

Implementations§

Source§

impl JsObject

Source

pub fn new(object: Object) -> Self

Create a new GcObject from a Object.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn equals(lhs: &Self, rhs: &Self) -> bool

Checks if the garbage collected memory is the same.

Source

pub fn is<T>(&self) -> bool
where 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.

Source

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.

Source

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.

Source

pub fn prototype_instance(&self) -> JsValue

Get the prototype of the object.

§Panics

Panics if the object is currently mutably borrowed.

Source

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.

Source

pub fn is_array(&self) -> bool

Checks if it an Array object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_array_iterator(&self) -> bool

Checks if it is an ArrayIterator object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_map(&self) -> bool

Checks if it is a Map object.pub

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_string(&self) -> bool

Checks if it a String object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_function(&self) -> bool

Checks if it a Function object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_symbol(&self) -> bool

Checks if it a Symbol object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_error(&self) -> bool

Checks if it an Error object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_boolean(&self) -> bool

Checks if it a Boolean object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_number(&self) -> bool

Checks if it a Number object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_bigint(&self) -> bool

Checks if it a BigInt object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_regexp(&self) -> bool

Checks if it a RegExp object.

§Panics

Panics if the object is currently mutably borrowed.

Source

pub fn is_ordinary(&self) -> bool

Checks if it an ordinary object.

§Panics

Panics if the object is currently mutably borrowed.

Source

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.

Source

pub fn to_property_descriptor( &self, context: &mut Context, ) -> JsResult<PropertyDescriptor>

Source

pub fn copy_data_properties<K>( &mut self, source: &JsValue, excluded_keys: Vec<K>, context: &mut Context, ) -> JsResult<()>
where K: Into<PropertyKey>,

7.3.25 CopyDataProperties ( target, source, excludedItems )

More information:

Source

pub fn insert_property<K, P>( &self, key: K, property: P, ) -> Option<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.

Source

pub fn is_callable(&self) -> bool

It determines if Object is a callable function with a [[Call]] internal method.

More information:

Source

pub fn is_constructable(&self) -> bool

It determines if Object is a function object with a [[Construct]] internal method.

More information:

Source

pub fn is_global(&self) -> bool

Returns true if the GcObject is the global for a Realm

Source§

impl JsObject

Source

pub fn is_extensible(&self, context: &mut Context) -> JsResult<bool>

Cehck if object is extensible.

More information:

Source

pub fn get<K>(&self, key: K, context: &mut Context) -> JsResult<JsValue>
where K: Into<PropertyKey>,

Get property from object or throw.

More information:

Source

pub fn set<K, V>( &self, key: K, value: V, throw: bool, context: &mut Context, ) -> JsResult<bool>
where K: Into<PropertyKey>, V: Into<JsValue>,

set property of object or throw if bool flag is passed.

More information:

Source

pub fn create_data_property<K, V>( &self, key: K, value: V, context: &mut Context, ) -> JsResult<bool>
where K: Into<PropertyKey>, V: Into<JsValue>,

Create data property

More information:

Source

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>,

Create data property or throw

More information:

Source

pub fn define_property_or_throw<K, P>( &self, key: K, desc: P, context: &mut Context, ) -> JsResult<bool>

Define property or throw.

More information:

Source

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:

Source

pub fn has_property<K>(&self, key: K, context: &mut Context) -> JsResult<bool>
where K: Into<PropertyKey>,

Check if object has property.

More information:

Source

pub fn has_own_property<K>( &self, key: K, context: &mut Context, ) -> JsResult<bool>
where K: Into<PropertyKey>,

Check if object has an own property.

More information:

Source

pub fn call( &self, this: &JsValue, args: &[JsValue], context: &mut Context, ) -> JsResult<JsValue>

Call this object.

§Panics

Panics if the object is currently mutably borrowed.

Source

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.

Source

pub fn set_integrity_level( &self, level: IntegrityLevel, context: &mut Context, ) -> JsResult<bool>

Make the object sealed or frozen.

More information:

Source

pub fn test_integrity_level( &self, level: IntegrityLevel, context: &mut Context, ) -> JsResult<bool>

Check if the object is sealed or frozen.

More information:

Trait Implementations§

Source§

impl AsRef<GcCell<Object>> for JsObject

Source§

fn as_ref(&self) -> &GcCell<Object>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for JsObject

Source§

fn clone(&self) -> JsObject

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsObject

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JsObject

Source§

fn default() -> JsObject

Returns the “default value” for a type. Read more
Source§

impl Drop for JsObject

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Finalize for JsObject

Source§

impl From<JsObject> for JsValue

Source§

fn from(object: JsObject) -> Self

Converts to this type from the input type.
Source§

impl Trace for JsObject

Source§

unsafe fn trace(&self)

Marks all contained Gcs.
Source§

unsafe fn root(&self)

Increments the root-count of all contained Gcs.
Source§

unsafe fn unroot(&self)

Decrements the root-count of all contained Gcs.
Source§

fn finalize_glue(&self)

Runs Finalize::finalize() on this object and all contained subobjects

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NativeObject for T
where T: Any + Debug + Trace,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &dyn Any.
Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Convert the Rust type which implements NativeObject to a &mut dyn Any.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V