#[repr(C)]
pub struct NapiEnv(_);

Implementations

create NapiEnv from raw napi_env

access raw napi_env from NapiEnv

This API returns the global object.

get node version the returned buffer is statically allocated and does not need to be freed.

get napi version

Return null object

Return undefined object

This API is used to convert from the C int32_t type to the JavaScript number type. The JavaScript number type is described in Section 6.1.6 of the ECMAScript Language Specification.

This API is used to convert from the C uint32_t type to the JavaScript number type. The JavaScript number type is described in Section 6.1.6 of the ECMAScript Language Specification.

This API is used to convert from the C int64_t type to the JavaScript number type. The JavaScript number type is described in Section 6.1.6 of the ECMAScript Language Specification. Note the complete range of int64_t cannot be represented with full precision in JavaScript. Integer values outside the range of Number.MIN_SAFE_INTEGER -(253 - 1) - Number.MAX_SAFE_INTEGER (253 - 1) will lose precision.

This API is used to convert from the C double type to the JavaScript number type. The JavaScript number type is described in Section 6.1.6 of the ECMAScript Language Specification.

This API creates a JavaScript string value from a UTF8-encoded C string. The native string is copied. The JavaScript string type is described in Section 6.1.4 of the ECMAScript Language Specification.

Create an empty js array.

Create a bigint_int64.

Create a bigint_unt64.

Create a boolean.

Create a Buffer

Create a Buffer from u8

Create an ArrayBuffer

Create a Date.

This API creates a JavaScript symbol value from a UTF8-encoded C string. The JavaScript symbol type is described in Section 19.4 of the ECMAScript Language Specification.

Symbol with description.

This API allocates a default JavaScript Object. It is the equivalent of doing new Object() in JavaScript. The JavaScript Object type is described in Section 6.1.7 of the ECMAScript Language Specification.

The async context

Create an external data.

Create a js function with a rust closure.

Create a named js function with a rust closure.

Create a named js function with a rust function

Create a js function with a rust function

Create a js class with a rust closure

Create an async work with shared state

Create a promise with a work & complete closure.

Create a NapiThreadsafeFunction.

This method allows the efficient definition of multiple properties on a given object. The properties are defined using property descriptors (see napi_property_descriptor). Given an array of such property descriptors, this API will set the properties on the object one at a time, as defined by DefineOwnProperty() (described in Section 9.1.6 of the ECMA-262 specification).

This API throws a JavaScript Error with the text provided.

This API throws a JavaScript Error with the text provided.

This API throws a JavaScript TypeError with the text provided.

This API throws a JavaScript TypeError with the text provided.

This API throws a JavaScript TypeError with the text provided.

This API throws a JavaScript TypeError with the text provided.

Get and clear last exception This API can be called even if there is a pending JavaScript exception.

This API retrieves a napi_extended_error_info structure with information about the last error that occurred.

The content of the napi_extended_error_info returned is only valid up until a Node-API function is called on the same env. This includes a call to napi_is_exception_pending so it may often be necessary to make a copy of the information so that it can be used later. The pointer returned in error_message points to a statically-defined string so it is safe to use that pointer if you have copied it out of the error_message field (which will be overwritten) before another Node-API function was called.

Do not rely on the content or format of any of the extended information as it is not subject to SemVer and may change at any time. It is intended only for logging purposes.

This API can be called even if there is a pending JavaScript exception.

Return true if an exception is pending. This API can be called even if there is a pending JavaScript exception.

Create a js Error.

Trigger an ‘uncaughtException’ in JavaScript. Useful if an async callback throws an exception with no way to recover.

Create a handle scope

Run in a scope.

Create a escapable handle scope

Run in an escapable scope.

Registers fun as a function to be run with the arg parameter once the current Node.js environment exits.

A function can safely be specified multiple times with different arg values.

In that case, it will be called multiple times as well. Providing the same fun and arg values multiple times is not allowed and will lead the process to abort.

The hooks will be called in reverse order, i.e. the most recently added one will be called first.

Removing this hook can be done by using napi_remove_env_cleanup_hook. Typically, that happens when the resource for which this hook was added is being torn down anyway. For asynchronous cleanup, napi_add_async_cleanup_hook is available.

Registers hook, which is a function of type napi_async_cleanup_hook, as a function to be run with the remove_handle and arg parameters once the current Node.js environment exits.

Unlike napi_add_env_cleanup_hook, the hook is allowed to be asynchronous.

Otherwise, behavior generally matches that of napi_add_env_cleanup_hook.

If remove_handle is not NULL, an opaque value will be stored in it that must later be passed to napi_remove_async_cleanup_hook, regardless of whether the hook has already been invoked. Typically, that happens when the resource for which this hook was added is being torn down anyway.

This function gives V8 an indication of the amount of externally allocated memory that is kept alive by JavaScript objects (i.e. a JavaScript object that points to its own memory allocated by a native module). Registering externally allocated memory will trigger global garbage collections more often than it would otherwise.

This function executes a string of JavaScript code and returns its result with the following caveats:

  • Unlike eval, this function does not allow the script to access the current lexical scope, and therefore also does not allow to access the module scope, meaning that pseudo-globals such as require will not be available.
  • The script can access the global scope. Function and var declarations in the script will be added to the global object. Variable declarations made using let and const will be visible globally, but will not be added to the global object.
  • The value of this is global within the script.

This API associates data with the currently running Agent. data can later be retrieved using napi_get_instance_data(). Any existing data associated with the currently running Agent which was set by means of a previous call to napi_set_instance_data() will be overwritten. If a finalize_cb was provided by the previous call, it will not be called.

This API retrieves data that was previously associated with the currently running Agent via napi_set_instance_data(). If no data is set, the call will succeed and data will be set to NULL.

Trait Implementations

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.