mirror of
https://github.com/napi-rs/napi-rs.git
synced 2026-02-01 16:41:24 +00:00
18 lines
423 B
Rust
18 lines
423 B
Rust
use napi::bindgen_prelude::*;
|
|
|
|
#[napi]
|
|
pub async fn async_plus_100(p: Promise<u32>) -> Result<u32> {
|
|
let v = p.await?;
|
|
Ok(v + 100)
|
|
}
|
|
|
|
#[napi]
|
|
pub fn call_then_on_promise(mut input: PromiseRaw<u32>) -> Result<PromiseRaw<String>> {
|
|
input.then(|v| Ok(format!("{}", v)))
|
|
}
|
|
|
|
#[napi]
|
|
pub fn call_catch_on_promise(mut input: PromiseRaw<u32>) -> Result<PromiseRaw<String>> {
|
|
input.catch(|e: String| Ok(format!("{}", e)))
|
|
}
|