Function napi_h::bindgen_prelude::get_c_callback
source · pub fn get_c_callback(raw_fn: ExportRegisterCallback) -> Result<Callback>
Expand description
Get C Callback
from defined Rust fn
#[napi]
fn some_fn() -> u32 {
1
}
#[napi]
fn create_obj(env: Env) -> Result<JsObject> {
let mut obj = env.create_object()?;
obj.define_property(&[Property::new("getter")?.with_getter(get_c_callback(some_fn_js_function)?)])?;
Ok(obj)
}
console.log(createObj().getter) // 1