| Crates.io | napi-derive-ohos |
| lib.rs | napi-derive-ohos |
| version | 1.1.0 |
| created_at | 2023-11-22 06:26:34.634219+00 |
| updated_at | 2025-07-26 02:43:07.08093+00 |
| description | N-API procedural macros |
| homepage | |
| repository | https://github.com/ohos-rs/ohos-rs |
| max_upload_size | |
| id | 1044906 |
| size | 93,827 |
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();
}