pub struct ConstructorBuilder<'ctx> { /* private fields */ }Expand description
Builder for creating constructors objects, like Array.
Implementations§
Source§impl<'ctx> ConstructorBuilder<'ctx>
impl<'ctx> ConstructorBuilder<'ctx>
Sourcepub fn new(
context: &'ctx mut Context,
function: NativeFunction,
) -> ConstructorBuilder<'ctx>
pub fn new( context: &'ctx mut Context, function: NativeFunction, ) -> ConstructorBuilder<'ctx>
Create a new ConstructorBuilder.
Sourcepub fn method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize,
) -> &mut Selfwhere
B: Into<FunctionBinding>,
pub fn method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize,
) -> &mut Selfwhere
B: Into<FunctionBinding>,
Add new method to the constructors prototype.
Sourcepub fn static_method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize,
) -> &mut Selfwhere
B: Into<FunctionBinding>,
pub fn static_method<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize,
) -> &mut Selfwhere
B: Into<FunctionBinding>,
Add new static method to the constructors object itself.
Sourcepub fn property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute,
) -> &mut Self
pub fn property<K, V>( &mut self, key: K, value: V, attribute: Attribute, ) -> &mut Self
Add new data property to the constructor’s prototype.
Sourcepub fn static_property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute,
) -> &mut Self
pub fn static_property<K, V>( &mut self, key: K, value: V, attribute: Attribute, ) -> &mut Self
Add new static data property to the constructor object itself.
Sourcepub fn accessor<K>(
&mut self,
key: K,
get: Option<JsFunction>,
set: Option<JsFunction>,
attribute: Attribute,
) -> &mut Selfwhere
K: Into<PropertyKey>,
pub fn accessor<K>(
&mut self,
key: K,
get: Option<JsFunction>,
set: Option<JsFunction>,
attribute: Attribute,
) -> &mut Selfwhere
K: Into<PropertyKey>,
Add new accessor property to the constructor’s prototype.
Sourcepub fn static_accessor<K>(
&mut self,
key: K,
get: Option<JsFunction>,
set: Option<JsFunction>,
attribute: Attribute,
) -> &mut Selfwhere
K: Into<PropertyKey>,
pub fn static_accessor<K>(
&mut self,
key: K,
get: Option<JsFunction>,
set: Option<JsFunction>,
attribute: Attribute,
) -> &mut Selfwhere
K: Into<PropertyKey>,
Add new static accessor property to the constructor object itself.
Sourcepub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Self
pub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Self
Add new property to the constructor’s prototype.
Sourcepub fn static_property_descriptor<K, P>(
&mut self,
key: K,
property: P,
) -> &mut Self
pub fn static_property_descriptor<K, P>( &mut self, key: K, property: P, ) -> &mut Self
Add new static property to the constructor object itself.
Sourcepub fn length(&mut self, length: usize) -> &mut Self
pub fn length(&mut self, length: usize) -> &mut Self
Specify how many arguments the constructor function takes.
Default is 0.
Sourcepub fn name<N>(&mut self, name: N) -> &mut Self
pub fn name<N>(&mut self, name: N) -> &mut Self
Specify the name of the constructor function.
Default is "[object]"
Sourcepub fn callable(&mut self, callable: bool) -> &mut Self
pub fn callable(&mut self, callable: bool) -> &mut Self
Specify whether the constructor function can be called.
Default is true
Sourcepub fn constructor(&mut self, constructor: bool) -> &mut Self
pub fn constructor(&mut self, constructor: bool) -> &mut Self
Specify whether the constructor function can be called with new keyword.
Default is true
Sourcepub fn inherit<O: Into<JsPrototype>>(&mut self, prototype: O) -> &mut Self
pub fn inherit<O: Into<JsPrototype>>(&mut self, prototype: O) -> &mut Self
Specify the parent prototype which objects created by this constructor inherit from.
Default is Object.prototype
Sourcepub fn custom_prototype<O: Into<JsPrototype>>(
&mut self,
prototype: O,
) -> &mut Self
pub fn custom_prototype<O: Into<JsPrototype>>( &mut self, prototype: O, ) -> &mut Self
Specify the [[Prototype]] internal field of this constructor.
Default is Function.prototype
Sourcepub fn has_prototype_property(
&mut self,
has_prototype_property: bool,
) -> &mut Self
pub fn has_prototype_property( &mut self, has_prototype_property: bool, ) -> &mut Self
Specify whether the constructor function has a ‘prototype’ property.
Default is true
Sourcepub fn build(self) -> StandardConstructor
pub fn build(self) -> StandardConstructor
Build the constructor function object.
Trait Implementations§
Auto Trait Implementations§
impl<'ctx> !RefUnwindSafe for ConstructorBuilder<'ctx>
impl<'ctx> !Send for ConstructorBuilder<'ctx>
impl<'ctx> !Sync for ConstructorBuilder<'ctx>
impl<'ctx> !UnwindSafe for ConstructorBuilder<'ctx>
impl<'ctx> Freeze for ConstructorBuilder<'ctx>
impl<'ctx> Unpin for ConstructorBuilder<'ctx>
impl<'ctx> UnsafeUnpin for ConstructorBuilder<'ctx>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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.