Crates.io | napi-derive-ohos |
lib.rs | napi-derive-ohos |
version | 1.0.2 |
source | src |
created_at | 2023-11-22 06:26:34.634219 |
updated_at | 2024-11-09 01:50:49.052446 |
description | N-API procedural macros |
homepage | |
repository | https://github.com/ohos-rs/ohos-rs |
max_upload_size | |
id | 1044906 |
size | 78,802 |
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();
}