Struct boa_engine::object::JsObject
source · [−]pub struct JsObject { /* private fields */ }
Expand description
Garbage collected Object
.
Implementations
sourceimpl JsObject
impl JsObject
sourcepub fn empty() -> Self
pub fn empty() -> Self
Create a new empty JsObject
, with prototype
set to JsValue::Null
and data
set to ObjectData::ordinary
sourcepub fn from_proto_and_data<O: Into<Option<Self>>>(
prototype: O,
data: ObjectData
) -> Self
pub fn from_proto_and_data<O: Into<Option<Self>>>(
prototype: O,
data: ObjectData
) -> Self
The more general form of OrdinaryObjectCreate
and MakeBasicObject
.
Create a JsObject
and automatically set its internal methods and
internal slots from the data
provided.
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) -> bool where
T: NativeObject,
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.
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(&self) -> Ref<'_, JsPrototype>
pub fn prototype(&self) -> Ref<'_, JsPrototype>
sourcepub fn set_prototype(&self, prototype: JsPrototype) -> bool
pub fn set_prototype(&self, prototype: JsPrototype) -> bool
sourcepub fn is_array_iterator(&self) -> bool
pub fn is_array_iterator(&self) -> bool
sourcepub fn is_array_buffer(&self) -> bool
pub fn is_array_buffer(&self) -> bool
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
sourcepub fn is_generator(&self) -> bool
pub fn is_generator(&self) -> bool
sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
sourcepub fn is_typed_array(&self) -> bool
pub fn is_typed_array(&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>(
&self,
source: &JsValue,
excluded_keys: Vec<K>,
context: &mut Context
) -> JsResult<()> where
K: Into<PropertyKey>,
pub fn copy_data_properties<K>(
&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_constructor(&self) -> bool
pub fn is_constructor(&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.
sourcepub fn set_integrity_level(
&self,
level: IntegrityLevel,
context: &mut Context
) -> JsResult<bool>
pub fn set_integrity_level(
&self,
level: IntegrityLevel,
context: &mut Context
) -> JsResult<bool>
sourcepub fn test_integrity_level(
&self,
level: IntegrityLevel,
context: &mut Context
) -> JsResult<bool>
pub fn test_integrity_level(
&self,
level: IntegrityLevel,
context: &mut Context
) -> JsResult<bool>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for JsObject
impl !Send for JsObject
impl !Sync for JsObject
impl Unpin for JsObject
impl !UnwindSafe for JsObject
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> NativeObject for T where
T: Any + Debug + Trace,
impl<T> NativeObject for T where
T: Any + Debug + Trace,
sourceimpl<T> Pipe for T where
T: ?Sized,
impl<T> Pipe for T where
T: ?Sized,
sourcefn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
Pipes by value. This is generally the method you want to use. Read more
sourcefn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
Borrows self
and passes that borrow into the pipe function. Read more
sourcefn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
Mutably borrows self
and passes that borrow into the pipe function. Read more
sourcefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.borrow()
into the pipe function. Read more
sourcefn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
sourcefn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows self
, then passes self.as_ref()
into the pipe function.
sourcefn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
sourceimpl<T> Tap for T
impl<T> Tap for T
sourcefn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Immutable access to the Borrow<B>
of a value. Read more
sourcefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the BorrowMut<B>
of a value. Read more
sourcefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Immutable access to the AsRef<R>
view of a value. Read more
sourcefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Mutable access to the AsMut<R>
view of a value. Read more
sourcefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the Deref::Target
of a value. Read more
sourcefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the Deref::Target
of a value. Read more
sourcefn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls .tap()
only in debug builds, and is erased in release builds.
sourcefn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
sourcefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more