24 releases (5 stable)

new 1.0.4 Jan 13, 2025
1.0.3 Nov 20, 2024
1.0.1 Oct 27, 2024
1.0.0-beta.5 Jul 31, 2024
0.0.1 Nov 22, 2023

#1711 in Procedural macros

Download history 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 1061/week @ 2024-12-14 750/week @ 2024-12-21 457/week @ 2024-12-28 1127/week @ 2025-01-04 916/week @ 2025-01-11

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

MIT license

215KB
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