Struct nodex_api::scope::NapiHandleScope
source · [−]pub struct NapiHandleScope(_, _);
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
sourceimpl 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
sourceimpl Clone for NapiHandleScope
impl Clone for NapiHandleScope
sourcefn clone(&self) -> NapiHandleScope
fn clone(&self) -> NapiHandleScope
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for NapiHandleScope
impl Debug for NapiHandleScope
Auto Trait Implementations
impl RefUnwindSafe for NapiHandleScope
impl !Send for NapiHandleScope
impl !Sync for NapiHandleScope
impl Unpin for NapiHandleScope
impl UnwindSafe for NapiHandleScope
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more