alef 0.26.5

Opinionated polyglot binding generator for Rust libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
/// Wrapper that bridges a foreign JavaScript object to a Rust trait.
///
/// Holds the JS object via a persistent napi reference (`ObjectRef`) rather than
/// a borrowed `Object` transmuted to `'static`. The reference is released in
/// `dispose()` (and defensively in `Drop`) so the outstanding handle no longer
/// pins the libuv event loop, letting Node/worker threads exit cleanly.
pub struct {{ wrapper_name }} {
    env: napi::sys::napi_env,
    obj_ref: std::sync::Mutex<Option<napi::bindgen_prelude::ObjectRef<false>>>,
    cached_name: String,
    cancellation_token: std::sync::Arc<tokio_util::sync::CancellationToken>,
}