pub struct Object<'o> {
obj: Local<'o, *mut JSObject>,
}Fields§
§obj: Local<'o, *mut JSObject>Implementations§
Source§impl<'o> Object<'o>
impl<'o> Object<'o>
Sourcepub fn null(cx: &'o Context) -> Object<'o>
pub fn null(cx: &'o Context) -> Object<'o>
Creates a null “Object”.
Most operations on this will result in an error, so be wary of where it is used.
Sourcepub fn global(cx: &'o Context) -> Object<'o>
pub fn global(cx: &'o Context) -> Object<'o>
Returns the current global object or null if one has not been initialised yet.
Sourcepub fn has<'cx, K: ToPropertyKey<'cx>>(&self, cx: &'cx Context, key: K) -> bool
pub fn has<'cx, K: ToPropertyKey<'cx>>(&self, cx: &'cx Context, key: K) -> bool
Checks if the Object has a value at the given key.
Sourcepub fn has_own<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
) -> bool
pub fn has_own<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, ) -> bool
Checks if the Object has its own value at the given key.
An object owns its properties if they are not inherited from a prototype.
Sourcepub fn get<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
) -> Result<Option<Value<'cx>>>
pub fn get<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, ) -> Result<Option<Value<'cx>>>
Sourcepub fn get_as<'cx, K: ToPropertyKey<'cx>, T: FromValue<'cx>>(
&self,
cx: &'cx Context,
key: K,
strict: bool,
config: T::Config,
) -> Result<Option<T>>
pub fn get_as<'cx, K: ToPropertyKey<'cx>, T: FromValue<'cx>>( &self, cx: &'cx Context, key: K, strict: bool, config: T::Config, ) -> Result<Option<T>>
Sourcepub fn get_descriptor<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
) -> Result<Option<PropertyDescriptor<'cx>>>
pub fn get_descriptor<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, ) -> Result<Option<PropertyDescriptor<'cx>>>
Sourcepub fn set<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
value: &Value<'_>,
) -> bool
pub fn set<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, value: &Value<'_>, ) -> bool
Sourcepub fn set_as<'cx, K: ToPropertyKey<'cx>, T: ToValue<'cx> + ?Sized>(
&self,
cx: &'cx Context,
key: K,
value: &T,
) -> bool
pub fn set_as<'cx, K: ToPropertyKey<'cx>, T: ToValue<'cx> + ?Sized>( &self, cx: &'cx Context, key: K, value: &T, ) -> bool
Sets the Rust type at the given key of the Object.
Returns false if the property cannot be set.
Sourcepub fn define<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
value: &Value<'_>,
attrs: PropertyFlags,
) -> bool
pub fn define<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, value: &Value<'_>, attrs: PropertyFlags, ) -> bool
Sourcepub fn define_as<'cx, K: ToPropertyKey<'cx>, T: ToValue<'cx> + ?Sized>(
&self,
cx: &'cx Context,
key: K,
value: &T,
attrs: PropertyFlags,
) -> bool
pub fn define_as<'cx, K: ToPropertyKey<'cx>, T: ToValue<'cx> + ?Sized>( &self, cx: &'cx Context, key: K, value: &T, attrs: PropertyFlags, ) -> bool
Defines the Rust type at the given key of the Object with the given attributes.
Returns false if the property cannot be defined.
Sourcepub fn define_method<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
method: NativeFunction,
nargs: u32,
attrs: PropertyFlags,
) -> Function<'cx>
pub fn define_method<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, method: NativeFunction, nargs: u32, attrs: PropertyFlags, ) -> Function<'cx>
Defines a method with the given name, and the given number of arguments and attributes on the Object.
Parameters are similar to create_function_spec.
Sourcepub unsafe fn define_methods(
&self,
cx: &Context,
methods: &[JSFunctionSpec],
) -> bool
pub unsafe fn define_methods( &self, cx: &Context, methods: &[JSFunctionSpec], ) -> bool
Defines methods on the objects using the given specs.
The final element of the methods slice must be JSFunctionSpec::ZERO.
They can be created through function_spec.
Sourcepub unsafe fn define_methods_with_help(
&self,
cx: &Context,
methods: &[JSFunctionSpecWithHelp],
) -> bool
pub unsafe fn define_methods_with_help( &self, cx: &Context, methods: &[JSFunctionSpecWithHelp], ) -> bool
Defines methods on the objects using the given specs, with help.
The final element of the methods slice must be JSFunctionSpecWithHelp::ZERO.
Sourcepub unsafe fn define_properties(
&self,
cx: &Context,
properties: &[JSPropertySpec],
) -> bool
pub unsafe fn define_properties( &self, cx: &Context, properties: &[JSPropertySpec], ) -> bool
Defines properties on the object using the given specs.
The final element of the properties slice must be JSPropertySpec::ZERO.
Sourcepub fn delete<'cx, K: ToPropertyKey<'cx>>(
&self,
cx: &'cx Context,
key: K,
) -> bool
pub fn delete<'cx, K: ToPropertyKey<'cx>>( &self, cx: &'cx Context, key: K, ) -> bool
Deletes the Value at the given index.
Returns false if the element cannot be deleted.
Sourcepub fn get_builtin_class(&self, cx: &Context) -> ESClass
pub fn get_builtin_class(&self, cx: &Context) -> ESClass
Gets the builtin class of the object as described in the ECMAScript specification.
Returns ESClass::Other for other projects or proxies that cannot be unwrapped.
Sourcepub fn is_boxed_primitive(&self, cx: &Context) -> Option<ESClass>
pub fn is_boxed_primitive(&self, cx: &Context) -> Option<ESClass>
Returns the builtin class of the object if it a wrapper around a primitive.
The boxed types are Boolean, Number, String and BigInt
Sourcepub fn unbox_primitive<'cx>(&self, cx: &'cx Context) -> Option<Value<'cx>>
pub fn unbox_primitive<'cx>(&self, cx: &'cx Context) -> Option<Value<'cx>>
Unboxes primitive wrappers. See Object::is_boxed_primitive for details.
Sourcepub fn keys<'cx>(
&self,
cx: &'cx Context,
flags: Option<IteratorFlags>,
) -> ObjectKeysIter<'cx> ⓘ
pub fn keys<'cx>( &self, cx: &'cx Context, flags: Option<IteratorFlags>, ) -> ObjectKeysIter<'cx> ⓘ
pub fn iter<'cx, 's>(
&'s self,
cx: &'cx Context,
flags: Option<IteratorFlags>,
) -> ObjectIter<'cx, 's> ⓘwhere
'o: 'cx,
pub fn to_hashmap<'cx>(
&self,
cx: &'cx Context,
flags: Option<IteratorFlags>,
) -> Result<HashMap<OwnedKey<'cx>, Value<'cx>>>where
'o: 'cx,
pub fn into_local(self) -> Local<'o, *mut JSObject>
Methods from Deref<Target = Local<'o, *mut JSObject>>§
Sourcepub fn handle_mut(&mut self) -> MutableHandle<'local, T>
pub fn handle_mut(&mut self) -> MutableHandle<'local, T>
Forms a Handle to the Local which can be passed to SpiderMonkey APIs.
§Panics
Panics when a Local::Handle is passed.
pub fn get(&self) -> T
Trait Implementations§
Auto Trait Implementations§
impl<'o> Freeze for Object<'o>
impl<'o> RefUnwindSafe for Object<'o>
impl<'o> !Send for Object<'o>
impl<'o> !Sync for Object<'o>
impl<'o> Unpin for Object<'o>
impl<'o> !UnwindSafe for Object<'o>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<'cx, T> FromArgument<'_, 'cx> for Twhere
T: FromValue<'cx>,
impl<'cx, T> FromArgument<'_, 'cx> for Twhere
T: FromValue<'cx>,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes