[][src]Trait nj_core::JSClass

pub trait JSClass: Sized {
    const CLASS_NAME: &'static str;

    fn create_from_js(
        js_env: &JsEnv,
        cb: napi_callback_info
    ) -> Result<(Self, JsCallback), NjError>;
fn set_constructor(constructor: napi_ref);
fn get_constructor() -> napi_ref; fn new_instance(
        js_env: &JsEnv,
        js_args: Vec<napi_value>
    ) -> Result<napi_value, NjError> { ... }
fn unwrap_mut(
        js_env: &JsEnv,
        instance: napi_value
    ) -> Result<&'static mut Self, NjError> { ... }
fn unwrap(
        js_env: &JsEnv,
        instance: napi_value
    ) -> Result<&'static Self, NjError> { ... }
fn properties() -> PropertiesBuilder { ... }
fn js_init(js_exports: &mut JsExports) -> Result<(), NjError> { ... }
extern "C" fn js_new(env: napi_env, info: napi_callback_info) -> napi_value { ... }
extern "C" fn js_finalize(
        _env: napi_env,
        finalize_data: *mut c_void,
        _finalize_hint: *mut c_void
    ) { ... } }

Associated Constants

const CLASS_NAME: &'static str

Loading content...

Required methods

fn create_from_js(
    js_env: &JsEnv,
    cb: napi_callback_info
) -> Result<(Self, JsCallback), NjError>

fn set_constructor(constructor: napi_ref)

fn get_constructor() -> napi_ref

Loading content...

Provided methods

fn new_instance(
    js_env: &JsEnv,
    js_args: Vec<napi_value>
) -> Result<napi_value, NjError>

new instance

fn unwrap_mut(
    js_env: &JsEnv,
    instance: napi_value
) -> Result<&'static mut Self, NjError>

given instance, return my object

fn unwrap(
    js_env: &JsEnv,
    instance: napi_value
) -> Result<&'static Self, NjError>

fn properties() -> PropertiesBuilder

fn js_init(js_exports: &mut JsExports) -> Result<(), NjError>

define class and properties under exports

extern "C" fn js_new(env: napi_env, info: napi_callback_info) -> napi_value

call when Javascript class constructor is called For example: new Car(...)

extern "C" fn js_finalize(
    _env: napi_env,
    finalize_data: *mut c_void,
    _finalize_hint: *mut c_void
)

Loading content...

Implementors

Loading content...