napi-rs/examples/napi/src/external.rs

22 lines
400 B
Rust
Raw Normal View History

2021-11-21 17:11:15 +09:00
use napi::bindgen_prelude::*;
#[napi]
pub fn create_external(size: u32) -> External<u32> {
External::new(size)
}
#[napi]
pub fn create_external_string(content: String) -> External<String> {
External::new(content)
}
#[napi]
pub fn get_external(external: External<u32>) -> u32 {
*external
2021-11-21 17:11:15 +09:00
}
#[napi]
pub fn mutate_external(mut external: External<u32>, new_val: u32) {
*external = new_val;
2021-11-21 17:11:15 +09:00
}