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

    // Required methods
    fn create_from_js(
        js_env: &JsEnv,
        cb: *mut napi_callback_info__
    ) -> Result<(Self, JsCallback), NjError>;
    fn set_constructor(constructor: *mut napi_ref__);
    fn get_constructor() -> *mut napi_ref__;

    // Provided methods
    fn new_instance(
        js_env: &JsEnv,
        js_args: Vec<*mut napi_value__>
    ) -> Result<*mut napi_value__, NjError> { ... }
    fn unwrap_mut(
        js_env: &JsEnv,
        instance: *mut napi_value__
    ) -> Result<&'static mut Self, NjError> { ... }
    fn unwrap(
        js_env: &JsEnv,
        instance: *mut napi_value__
    ) -> Result<&'static Self, NjError> { ... }
    fn properties() -> PropertiesBuilder { ... }
    fn js_init(js_exports: &mut JsExports) -> Result<(), NjError> { ... }
    extern "C" fn js_new(
        env: *mut napi_env__,
        info: *mut napi_callback_info__
    ) -> *mut napi_value__ { ... }
    extern "C" fn js_finalize(
        _env: *mut napi_env__,
        finalize_data: *mut c_void,
        _finalize_hint: *mut c_void
    ) { ... }
}

Required Associated Constants§

source

const CLASS_NAME: &'static str

Required Methods§

Provided Methods§

source

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

new instance

source

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

given instance, return my object

source

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

source

fn properties() -> PropertiesBuilder

source

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

define class and properties under exports

source

extern "C" fn js_new( env: *mut napi_env__, info: *mut napi_callback_info__ ) -> *mut napi_value__

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

source

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

Object Safety§

This trait is not object safe.

Implementors§