pub trait JsClass<'js>:
Trace<'js>
+ JsLifetime<'js>
+ Sized {
type Mutable: Mutability;
const NAME: &'static str;
const KIND: ClassKind = ClassKind::Plain;
// Required method
fn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>>;
// Provided methods
fn prototype(ctx: &Ctx<'js>) -> Result<Option<Object<'js>>> { ... }
fn call<'a>(
this: &JsCell<'js, Self>,
params: Params<'a, 'js>,
) -> Result<Value<'js>> { ... }
fn exotic_get_property(
this: &JsCell<'js, Self>,
ctx: &Ctx<'js>,
_atom: Atom<'js>,
_receiver: Value<'js>,
) -> Result<Value<'js>> { ... }
fn exotic_set_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
_receiver: Value<'js>,
_value: Value<'js>,
) -> Result<bool> { ... }
fn exotic_delete_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<bool> { ... }
fn exotic_has_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<bool> { ... }
fn exotic_get_own_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<Option<PropertyDescriptor<'js>>> { ... }
fn exotic_get_own_property_names(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
) -> Result<Vec<PropertyName<'js>>> { ... }
}Expand description
The trait which allows Rust types to be used from JavaScript.
Required Associated Constants§
Provided Associated Constants§
Required Associated Types§
Sourcetype Mutable: Mutability
type Mutable: Mutability
Required Methods§
Sourcefn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>>
fn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>>
Returns a predefined constructor for this specific class type if there is one.
Provided Methods§
Sourcefn call<'a>(
this: &JsCell<'js, Self>,
params: Params<'a, 'js>,
) -> Result<Value<'js>>
fn call<'a>( this: &JsCell<'js, Self>, params: Params<'a, 'js>, ) -> Result<Value<'js>>
The function which will be called if Self::KIND is ClassKind::Callable and an object with this
class is called as if it is a function.
Sourcefn exotic_get_property(
this: &JsCell<'js, Self>,
ctx: &Ctx<'js>,
_atom: Atom<'js>,
_receiver: Value<'js>,
) -> Result<Value<'js>>
fn exotic_get_property( this: &JsCell<'js, Self>, ctx: &Ctx<'js>, _atom: Atom<'js>, _receiver: Value<'js>, ) -> Result<Value<'js>>
The function which will be called if a get property is performed on an object with this class
Sourcefn exotic_set_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
_receiver: Value<'js>,
_value: Value<'js>,
) -> Result<bool>
fn exotic_set_property( this: &JsCell<'js, Self>, _ctx: &Ctx<'js>, _atom: Atom<'js>, _receiver: Value<'js>, _value: Value<'js>, ) -> Result<bool>
The function which will be called if a set property is performed on an object with this class
Sourcefn exotic_delete_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<bool>
fn exotic_delete_property( this: &JsCell<'js, Self>, _ctx: &Ctx<'js>, _atom: Atom<'js>, ) -> Result<bool>
The function which will be called if a delete property is performed on an object with this class
Sourcefn exotic_has_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<bool>
fn exotic_has_property( this: &JsCell<'js, Self>, _ctx: &Ctx<'js>, _atom: Atom<'js>, ) -> Result<bool>
The function which will be called if has property or similar is called on an object with this class
Sourcefn exotic_get_own_property(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
_atom: Atom<'js>,
) -> Result<Option<PropertyDescriptor<'js>>>
fn exotic_get_own_property( this: &JsCell<'js, Self>, _ctx: &Ctx<'js>, _atom: Atom<'js>, ) -> Result<Option<PropertyDescriptor<'js>>>
Called to get the own property descriptor for a given property name.
Return Ok(Some(descriptor)) if the property exists, Ok(None) if it doesn’t.
Sourcefn exotic_get_own_property_names(
this: &JsCell<'js, Self>,
_ctx: &Ctx<'js>,
) -> Result<Vec<PropertyName<'js>>>
fn exotic_get_own_property_names( this: &JsCell<'js, Self>, _ctx: &Ctx<'js>, ) -> Result<Vec<PropertyName<'js>>>
Called to enumerate the own property names of this object.
Return a list of property names.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".