23 releases (4 stable)

new 1.0.3 Nov 20, 2024
1.0.1 Oct 27, 2024
1.0.0-beta.5 Jul 31, 2024
0.0.9 Mar 1, 2024
0.0.1 Nov 22, 2023

#1656 in Procedural macros

Download history 922/week @ 2024-07-31 838/week @ 2024-08-07 1587/week @ 2024-08-14 1011/week @ 2024-08-21 1105/week @ 2024-08-28 1188/week @ 2024-09-04 975/week @ 2024-09-11 562/week @ 2024-09-18 907/week @ 2024-09-25 959/week @ 2024-10-02 1079/week @ 2024-10-09 1237/week @ 2024-10-16 1107/week @ 2024-10-23 1061/week @ 2024-10-30 922/week @ 2024-11-06 514/week @ 2024-11-13

3,769 downloads per month
Used in ohos-xcomponent-binding

MIT license

210KB
6K SLoC

napi-derive

chat

Checkout more examples in examples folder

#[macro_use]
extern crate napi_derive;
use napi_ohos::bindgen_prelude::*;

#[napi]
fn fibonacci(n: u32) -> u32 {
  match n {
    1 | 2 => 1,
    _ => fibonacci_native(n - 1) + fibonacci_native(n - 2),
  }
}

#[napi]
fn get_cwd<T: Fn(String) -> Result<()>>(callback: T) {
  callback(env::current_dir().unwrap().to_string_lossy().to_string()).unwrap();
}

Dependencies

~0.6–1.2MB
~22K SLoC