pub struct JsGeneratorFunction { /* private fields */ }Expand description
JsGeneratorFunction provides a wrapper for Boa’s implementation of the ECMAScript GeneratorFunction builtin object.
Implementations§
Source§impl JsGeneratorFunction
impl JsGeneratorFunction
Sourcepub fn from_object(object: JsObject) -> JsResult<Self>
pub fn from_object(object: JsObject) -> JsResult<Self>
Creates a JsGeneratorFunction from a generator function JsObject.
More information:
Methods from Deref<Target = JsObject>§
Sourcepub fn downcast_ref<T: NativeObject>(&self) -> Option<Ref<'_, T>>
pub fn downcast_ref<T: NativeObject>(&self) -> Option<Ref<'_, T>>
Downcasts a reference to the object,
if the object is of type T.
§Panics
Panics if the object is currently mutably borrowed.
§Examples
#[derive(Debug, Trace, Finalize, JsData)]
struct CustomStruct;
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
// Downcast ref succeeds for the correct type.
assert!(obj.downcast_ref::<OrdinaryObject>().is_some());
// Returns `None` for a wrong type.
assert!(obj.downcast_ref::<CustomStruct>().is_none());Sourcepub fn downcast_mut<T: NativeObject>(&self) -> Option<RefMut<'_, T>>
pub fn downcast_mut<T: NativeObject>(&self) -> Option<RefMut<'_, T>>
Downcasts a mutable reference to the object,
if the object is type native object type T.
§Panics
Panics if the object is currently borrowed.
§Examples
#[derive(Debug, Trace, Finalize, JsData)]
struct CustomStruct;
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
// Downcast mut succeeds for the correct type.
assert!(obj.downcast_mut::<OrdinaryObject>().is_some());
// Returns `None` for a wrong type.
assert!(obj.downcast_mut::<CustomStruct>().is_none());Sourcepub fn is<T: NativeObject>(&self) -> bool
pub fn is<T: NativeObject>(&self) -> bool
Checks if this object is an instance of a certain NativeObject.
§Panics
Panics if the object is currently mutably borrowed.
§Examples
#[derive(Debug, Trace, Finalize, JsData)]
struct CustomStruct;
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
assert!(obj.is::<OrdinaryObject>());
assert!(!obj.is::<CustomStruct>());Sourcepub fn is_ordinary(&self) -> bool
pub fn is_ordinary(&self) -> bool
Sourcepub fn is_array(&self) -> bool
pub fn is_array(&self) -> bool
Checks if it’s an Array object.
§Examples
let context = &mut Context::default();
let array = JsArray::new(context)?;
// A JsArray's inner JsObject is an array.
assert!(JsObject::from(array).is_array());
// An ordinary object is not an array.
let obj = JsObject::with_object_proto(context.intrinsics());
assert!(!obj.is_array());Sourcepub fn to_primitive(
&self,
context: &mut Context,
preferred_type: PreferredType,
) -> JsResult<JsValue>
pub fn to_primitive( &self, context: &mut Context, preferred_type: PreferredType, ) -> JsResult<JsValue>
The abstract operation ToPrimitive takes an input argument and an optional argument
PreferredType.
Sourcepub fn to_property_descriptor(
&self,
context: &mut Context,
) -> JsResult<PropertyDescriptor>
pub fn to_property_descriptor( &self, context: &mut Context, ) -> JsResult<PropertyDescriptor>
Sourcepub fn borrow(&self) -> Ref<'_, Object<T>>
pub fn borrow(&self) -> Ref<'_, Object<T>>
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.
§Examples
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
// Multiple immutable borrows are allowed.
let borrowed = obj.borrow();
assert!(borrowed.prototype().is_none());Sourcepub fn borrow_mut(&self) -> RefMut<'_, Object<T>>
pub fn borrow_mut(&self) -> RefMut<'_, Object<T>>
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.
§Examples
let context = &mut Context::default();
let obj = JsObject::from_proto_and_data(
context.intrinsics().constructors().object().prototype(),
OrdinaryObject,
);
// Set the prototype to `None` via a mutable borrow.
obj.borrow_mut().set_prototype(None);
assert!(obj.prototype().is_none());Sourcepub fn try_borrow(&self) -> StdResult<Ref<'_, Object<T>>, BorrowError>
pub fn try_borrow(&self) -> StdResult<Ref<'_, Object<T>>, 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.
§Examples
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
// Non-panicking immutable borrow.
let result = obj.try_borrow();
assert!(result.is_ok());Sourcepub fn try_borrow_mut(&self) -> StdResult<RefMut<'_, Object<T>>, BorrowMutError>
pub fn try_borrow_mut(&self) -> StdResult<RefMut<'_, Object<T>>, 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.
§Examples
let obj = JsObject::from_proto_and_data(None, OrdinaryObject);
// Non-panicking mutable borrow.
let result = obj.try_borrow_mut();
assert!(result.is_ok());Sourcepub fn prototype(&self) -> JsPrototype
pub fn prototype(&self) -> JsPrototype
Get the prototype of the object.
§Panics
Panics if the object is currently mutably borrowed.
§Examples
let context = &mut Context::default();
let obj = JsObject::with_object_proto(context.intrinsics());
assert!(obj.prototype().is_some());
let null_obj = JsObject::with_null_proto();
assert!(null_obj.prototype().is_none());Sourcepub fn set_prototype(&self, prototype: JsPrototype) -> bool
pub fn set_prototype(&self, prototype: JsPrototype) -> bool
Set the prototype of the object.
§Panics
Panics if the object is currently mutably borrowed
§Examples
let context = &mut Context::default();
let obj = JsObject::with_object_proto(context.intrinsics());
assert!(obj.prototype().is_some());
// Set the prototype to `None`.
obj.set_prototype(None);
assert!(obj.prototype().is_none());Sourcepub fn insert_property<K, P>(&self, key: K, property: P) -> bool
pub fn insert_property<K, P>(&self, key: K, property: P) -> bool
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, than true is returned
with that field, otherwise false 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:
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>
pub fn set<K, V>( &self, key: K, value: V, throw: bool, context: &mut Context, ) -> JsResult<bool>
Sourcepub fn create_data_property<K, V>(
&self,
key: K,
value: V,
context: &mut Context,
) -> JsResult<bool>
pub fn create_data_property<K, V>( &self, key: K, value: V, context: &mut Context, ) -> JsResult<bool>
Sourcepub fn create_data_property_or_throw<K, V>(
&self,
key: K,
value: V,
context: &mut Context,
) -> JsResult<bool>
pub fn create_data_property_or_throw<K, V>( &self, key: K, value: V, context: &mut Context, ) -> JsResult<bool>
Sourcepub fn define_property_or_throw<K, P>(
&self,
key: K,
desc: P,
context: &mut Context,
) -> JsResult<bool>
pub fn define_property_or_throw<K, P>( &self, key: K, desc: P, context: &mut Context, ) -> JsResult<bool>
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 own_property_keys(
&self,
context: &mut Context,
) -> JsResult<Vec<PropertyKey>>
pub fn own_property_keys( &self, context: &mut Context, ) -> JsResult<Vec<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>
Call ( F, V [ , argumentsList ] )
§Panics
Panics if the object is currently mutably borrowed.
More information:
Sourcepub fn construct(
&self,
args: &[JsValue],
new_target: Option<&Self>,
context: &mut Context,
) -> JsResult<Self>
pub fn construct( &self, args: &[JsValue], new_target: Option<&Self>, context: &mut Context, ) -> JsResult<Self>
Construct ( F [ , argumentsList [ , newTarget ] ] )
Construct an instance of this object with the specified arguments.
§Panics
Panics if the object is currently mutably borrowed.
More information:
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>
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>,
Trait Implementations§
Source§impl Clone for JsGeneratorFunction
impl Clone for JsGeneratorFunction
Source§fn clone(&self) -> JsGeneratorFunction
fn clone(&self) -> JsGeneratorFunction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JsGeneratorFunction
impl Debug for JsGeneratorFunction
Source§impl Deref for JsGeneratorFunction
impl Deref for JsGeneratorFunction
Source§impl Drop for JsGeneratorFunction
impl Drop for JsGeneratorFunction
Source§impl From<JsGeneratorFunction> for JsObject
impl From<JsGeneratorFunction> for JsObject
Source§fn from(o: JsGeneratorFunction) -> Self
fn from(o: JsGeneratorFunction) -> Self
Source§impl From<JsGeneratorFunction> for JsValue
impl From<JsGeneratorFunction> for JsValue
Source§fn from(o: JsGeneratorFunction) -> Self
fn from(o: JsGeneratorFunction) -> Self
Source§impl Trace for JsGeneratorFunction
impl Trace for JsGeneratorFunction
Source§unsafe fn trace_non_roots(&self)
unsafe fn trace_non_roots(&self)
Source§fn run_finalizer(&self)
fn run_finalizer(&self)
Finalize::finalize on this object and all
contained subobjects.Source§impl TryFromJs for JsGeneratorFunction
impl TryFromJs for JsGeneratorFunction
Auto Trait Implementations§
impl Freeze for JsGeneratorFunction
impl !RefUnwindSafe for JsGeneratorFunction
impl !Send for JsGeneratorFunction
impl !Sync for JsGeneratorFunction
impl Unpin for JsGeneratorFunction
impl UnsafeUnpin for JsGeneratorFunction
impl !UnwindSafe for JsGeneratorFunction
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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.