napi-rs/napi/src/module.rs
LongYinan 1a3621b727
feat(napi): major upgrades for napi@1
1. inline everything
2. change `check_status` and `type_of` to macro
3. provide #[module_exports] macro
4. remove debug and repr[transparent] for ffi struct
2020-11-26 11:31:49 +08:00

17 lines
404 B
Rust

use crate::{Callback, Env, JsObject, Result};
pub struct Module {
pub env: Env,
pub exports: JsObject,
}
#[deprecated(since = "1.0.0", note = "[module_exports] macro instead")]
impl Module {
pub fn create_named_method(&mut self, name: &str, function: Callback) -> Result<()> {
self
.exports
.set_named_property(name, self.env.create_function(name, function)?)?;
Ok(())
}
}