23 releases (4 stable)

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

#1701 in Procedural macros

Download history 1158/week @ 2024-08-31 1051/week @ 2024-09-07 738/week @ 2024-09-14 828/week @ 2024-09-21 724/week @ 2024-09-28 1327/week @ 2024-10-05 987/week @ 2024-10-12 1128/week @ 2024-10-19 1025/week @ 2024-10-26 968/week @ 2024-11-02 899/week @ 2024-11-09 1033/week @ 2024-11-16 703/week @ 2024-11-23 690/week @ 2024-11-30 966/week @ 2024-12-07 1055/week @ 2024-12-14

3,546 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.7–1.2MB
~22K SLoC