Struct boa_engine::class::ClassBuilder
source · pub struct ClassBuilder<'ctx, 'host> { /* private fields */ }
Expand description
Class builder which allows adding methods and static methods to the class.
Implementations§
source§impl<'ctx, 'host> ClassBuilder<'ctx, 'host>
impl<'ctx, 'host> ClassBuilder<'ctx, 'host>
sourcepub fn method<N>(
&mut self,
name: N,
length: usize,
function: NativeFunction
) -> &mut Selfwhere
N: AsRef<str>,
pub fn method<N>( &mut self, name: N, length: usize, function: NativeFunction ) -> &mut Selfwhere N: AsRef<str>,
Add a method to the class.
It is added to prototype
.
sourcepub fn static_method<N>(
&mut self,
name: N,
length: usize,
function: NativeFunction
) -> &mut Selfwhere
N: AsRef<str>,
pub fn static_method<N>( &mut self, name: N, length: usize, function: NativeFunction ) -> &mut Selfwhere N: AsRef<str>,
Add a static method to the class.
It is added to class object itself.
sourcepub fn property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn property<K, V>( &mut self, key: K, value: V, attribute: Attribute ) -> &mut Selfwhere K: Into<PropertyKey>, V: Into<JsValue>,
Add a data property to the class, with the specified attribute.
It is added to prototype
.
sourcepub fn static_property<K, V>(
&mut self,
key: K,
value: V,
attribute: Attribute
) -> &mut Selfwhere
K: Into<PropertyKey>,
V: Into<JsValue>,
pub fn static_property<K, V>( &mut self, key: K, value: V, attribute: Attribute ) -> &mut Selfwhere K: Into<PropertyKey>, V: Into<JsValue>,
Add a static data property to the class, with the specified attribute.
It is added to class 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 an accessor property to the class, with the specified attribute.
It is added to 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 a static accessor property to the class, with the specified attribute.
It is added to class object itself.
sourcepub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn property_descriptor<K, P>(&mut self, key: K, property: P) -> &mut Selfwhere K: Into<PropertyKey>, P: Into<PropertyDescriptor>,
Add a property descriptor to the class, with the specified attribute.
It is added to prototype
.
sourcepub fn static_property_descriptor<K, P>(
&mut self,
key: K,
property: P
) -> &mut Selfwhere
K: Into<PropertyKey>,
P: Into<PropertyDescriptor>,
pub fn static_property_descriptor<K, P>( &mut self, key: K, property: P ) -> &mut Selfwhere K: Into<PropertyKey>, P: Into<PropertyDescriptor>,
Add a static property descriptor to the class, with the specified attribute.
It is added to class object itself.
Trait Implementations§
Auto Trait Implementations§
impl<'ctx, 'host> !RefUnwindSafe for ClassBuilder<'ctx, 'host>
impl<'ctx, 'host> !Send for ClassBuilder<'ctx, 'host>
impl<'ctx, 'host> !Sync for ClassBuilder<'ctx, 'host>
impl<'ctx, 'host> Unpin for ClassBuilder<'ctx, 'host>
impl<'ctx, 'host> !UnwindSafe for ClassBuilder<'ctx, 'host>
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> 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) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
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 ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
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) -> Rwhere
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) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
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)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
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)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.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)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.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)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.