napi-derive-ohos

Crates.ionapi-derive-ohos
lib.rsnapi-derive-ohos
version1.1.0
created_at2023-11-22 06:26:34.634219+00
updated_at2025-07-26 02:43:07.08093+00
descriptionN-API procedural macros
homepage
repositoryhttps://github.com/ohos-rs/ohos-rs
max_upload_size
id1044906
size93,827
richerfu (richerfu)

documentation

README

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();
}
Commit count: 3511

cargo fmt