napi-rs/test_module/src/lib.rs

69 lines
1.3 KiB
Rust
Raw Normal View History

2018-04-28 17:26:38 +09:00
#[macro_use]
extern crate napi;
#[macro_use]
extern crate napi_derive;
2020-08-26 01:07:27 +09:00
#[macro_use]
extern crate serde_derive;
2018-04-28 17:26:38 +09:00
use napi::{Module, Result};
#[cfg(napi4)]
mod libuv;
2020-07-08 01:59:09 +09:00
#[cfg(napi4)]
mod napi4;
#[cfg(napi5)]
mod napi5;
2020-07-10 20:14:32 +09:00
#[cfg(napi6)]
mod napi6;
2020-08-26 01:07:27 +09:00
#[cfg(napi4)]
mod tokio_rt;
2018-04-28 17:26:38 +09:00
mod arraybuffer;
mod buffer;
2020-08-03 00:31:22 +09:00
mod class;
2020-07-18 03:00:48 +09:00
mod either;
mod env;
mod error;
mod external;
2020-07-08 01:59:09 +09:00
mod function;
2020-10-03 01:05:43 +09:00
mod global;
2020-07-08 01:59:09 +09:00
mod napi_version;
mod object;
2020-08-26 01:07:27 +09:00
mod serde;
2020-08-03 15:34:58 +09:00
mod string;
mod symbol;
mod task;
2018-04-28 17:26:38 +09:00
2020-07-08 01:59:09 +09:00
use napi_version::get_napi_version;
register_module!(test_module, init);
fn init(module: &mut Module) -> Result<()> {
module.create_named_method("getNapiVersion", get_napi_version)?;
error::register_js(module)?;
string::register_js(module)?;
serde::register_js(module)?;
task::register_js(module)?;
external::register_js(module)?;
arraybuffer::register_js(module)?;
buffer::register_js(module)?;
either::register_js(module)?;
symbol::register_js(module)?;
function::register_js(module)?;
class::register_js(module)?;
env::register_js(module)?;
object::register_js(module)?;
2020-10-03 01:05:43 +09:00
global::register_js(module)?;
#[cfg(napi4)]
napi4::register_js(module)?;
#[cfg(napi4)]
tokio_rt::register_js(module)?;
2020-07-08 01:59:09 +09:00
#[cfg(napi4)]
libuv::read_file::register_js(module)?;
#[cfg(napi5)]
napi5::register_js(module)?;
2020-07-10 20:14:32 +09:00
#[cfg(napi6)]
napi6::register_js(module)?;
Ok(())
2018-04-28 17:26:38 +09:00
}