pub struct NapiHandleScope(/* private fields */);
Expand description
Node-API provides the ability to establish a new ‘scope’ to which newly created handles will be associated. Once those handles are no longer required, the scope can be ‘closed’ and any handles associated with the scope are invalidated. The methods available to open/close scopes are napi_open_handle_scope and napi_close_handle_scope.
Node-API only supports a single nested hierarchy of scopes. There is only one active scope at any time, and all new handles will be associated with that scope while it is active. Scopes must be closed in the reverse order from which they are opened. In addition, all scopes created within a native method must be closed before returning from that method.
Implementations§
Source§impl NapiHandleScope
impl NapiHandleScope
pub fn env(&self) -> NapiEnv
pub fn raw(&self) -> napi_handle_scope
Sourcepub fn open(env: NapiEnv) -> NapiResult<NapiHandleScope>
pub fn open(env: NapiEnv) -> NapiResult<NapiHandleScope>
This API opens a new scope.
Sourcepub fn close(&mut self) -> NapiResult<()>
pub fn close(&mut self) -> NapiResult<()>
This API closes the scope passed in. Scopes must be closed in the reverse order from which they were created. This API can be called even if there is a pending JavaScript exception.
Trait Implementations§
Source§impl Clone for NapiHandleScope
impl Clone for NapiHandleScope
Source§fn clone(&self) -> NapiHandleScope
fn clone(&self) -> NapiHandleScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more