pub trait JsClass<'js>: Trace<'js> {
type Mutable: Mutability;
const NAME: &'static str;
// Required methods
fn class_id() -> &'static ClassId;
fn prototype(ctx: &Ctx<'js>) -> Result<Option<Object<'js>>, Error>;
fn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>, Error>;
// Provided method
fn function() -> Option<StaticJsFn> { ... }
}
Expand description
The trait which allows Rust types to be used from JavaScript.
Required Associated Types§
sourcetype Mutable: Mutability
type Mutable: Mutability
Required Associated Constants§
Required Methods§
sourcefn prototype(ctx: &Ctx<'js>) -> Result<Option<Object<'js>>, Error>
fn prototype(ctx: &Ctx<'js>) -> Result<Option<Object<'js>>, Error>
Returns the class prototype,
sourcefn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>, Error>
fn constructor(ctx: &Ctx<'js>) -> Result<Option<Constructor<'js>>, Error>
Returns a predefined constructor for this specific class type if there is one.
Provided Methods§
sourcefn function() -> Option<StaticJsFn>
fn function() -> Option<StaticJsFn>
A possible call function.
Returning a function from this method makes any objects with this class callable as if it is a function object..
Object Safety§
This trait is not object safe.