napi-derive-ohos

Crates.ionapi-derive-ohos
lib.rsnapi-derive-ohos
version1.0.2
sourcesrc
created_at2023-11-22 06:26:34.634219
updated_at2024-11-09 01:50:49.052446
descriptionN-API procedural macros
homepage
repositoryhttps://github.com/ohos-rs/ohos-rs
max_upload_size
id1044906
size78,802
Richer (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: 3315

cargo fmt