Struct nodex_api::scope::NapiEscapableHandleScope
source · [−]pub struct NapiEscapableHandleScope(_, _);
Expand description
When nesting scopes, there are cases where a handle from an inner scope needs to live beyond the lifespan of that scope. Node-API supports an ‘escapable scope’ in order to support this case. An escapable scope allows one handle to be ‘promoted’ so that it ‘escapes’ the current scope and the lifespan of the handle changes from the current scope to that of the outer scope.
The methods available to open/close escapable scopes are napi_open_escapable_handle_scope and napi_close_escapable_handle_scope.
The request to promote a handle is made through napi_escape_handle which can only be called once.
Implementations
This API opens a new scope from which one object can be promoted to the outer scope.
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.
This API promotes the handle to the JavaScript object so that it is valid for the lifetime of the outer scope. It can only be called once per scope. If it is called more than once an error will be returned.
This API can be called even if there is a pending JavaScript exception.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NapiEscapableHandleScope
impl !Send for NapiEscapableHandleScope
impl !Sync for NapiEscapableHandleScope
impl Unpin for NapiEscapableHandleScope
impl UnwindSafe for NapiEscapableHandleScope
Blanket Implementations
Mutably borrows from an owned value. Read more