Module napi

Source

Re-exports§

pub use crate::napi::Env;
pub use crate::napi::js_values::TypedArrayType;
pub use crate::napi::JsFunction;
pub use crate::napi::js_values::JsUnknown as Unknown;
pub use crate::napi::JsDate as Date;
pub use self::js_values::*;

Modules§

bindgen_prelude
iterator
js_values
runtime
threadsafe_function

Structs§

AbortSignal
https://developer.mozilla.org/zh-CN/docs/Web/API/AbortController
Array
AsyncCleanupHook
Notice The hook will be removed if AsyncCleanupHook was dropped. If you want keep the hook until node process exited, call the AsyncCleanupHook::forget.
AsyncTask
AsyncWorkPromise
BigInt
https://nodejs.org/api/n-api.html#napi_create_bigint_words The resulting BigInt is calculated as: (–1)^sign_bit (words[0] × (2^64)^0 + words[1] × (2^64)^1 + …)
BigInt64Array
BigUint64Array
Buffer
Zero copy u8 vector shared between rust and napi. It’s designed to be used in async context, so it contains overhead to ensure the underlying data is not dropped. For non-async context, use BufferRef instead.
BufferSlice
Zero copy buffer slice shared between Rust and Node.js. It can only be used in non-async context and the lifetime is bound to the fn closure. If you want to use Node.js Buffer in async context or want to extend the lifetime, use Buffer instead.
CallContext
Function call context
ClassInstance
CleanupEnvHook
Created by Env::add_env_cleanup_hook And used by Env::remove_env_cleanup_hook
Env
Env is used to represent a context that the underlying N-API implementation can use to persist VM-specific state.
Error
Represent JsError. Return this Error in js_function, napi-rs will throw it as JsError for you. If you want throw it as TypeError or RangeError, you can use JsTypeError/JsRangeError::from(Error).throw_into(env)
ExtendedErrorInfo
External
Float32Array
Float64Array
Function
A JavaScript function. It can only live in the scope of a function call. If you want to use it outside the scope of a function call, you can turn it into a reference. By calling the create_ref method.
FunctionRef
A reference to a JavaScript function. It can be used to outlive the scope of the function.
Int8Array
Int16Array
Int32Array
JsError
JsRangeError
JsRc
JsSyntaxError
JsTypeError
NodeVersion
Null
Reference
Experimental feature
SharedReference
Experimental feature
Symbol
Uint8Array
Uint8ClampedArray
Uint8ClampedSlice
Zero copy Uint8ClampedArray slice shared between Rust and Node.js. It can only be used in non-async context and the lifetime is bound to the fn closure. If you want to use Node.js Uint8ClampedArray in async context or want to extend the lifetime, use Uint8ClampedArray instead.
Uint16Array
Uint32Array
Utf16String
WeakReference
i64n
i64 is converted to Number

Enums§

Either
Either3
Either4
Either5
Either6
Either7
Either8
Either9
Either10
Either11
Either12
Either13
Either14
Either15
Either16
Either17
Either18
Either19
Either20
Either21
Either22
Either23
Either24
Either25
Either26
Status
ValueType

Traits§

FromNapiMutRef
FromNapiRef
FromNapiValue
Generator
Implement a Iterator for the JavaScript Class. This feature is an experimental feature and is not yet stable.
JsRcExt
JsValuesTupleIntoVec
ObjectFinalize
Task
ToNapiValue
TypeName
ValidateNapiValue

Functions§

create_promise
get_c_callback
Get C Callback from defined Rust fn
get_js_function
Get JsFunction from defined Rust fn
napi_register_module_v1
Register the n-api module exports.
noop_finalize
This function could be used for create_buffer_with_borrowed_data and want do noting when Buffer finalized.
spawn_local
spawn_local_promise

Type Aliases§

Callback
ContextlessResult
ExportRegisterCallback
ModuleExportsCallback
Object
PromiseExecutor
Result
This
Undefined

Attribute Macros§

ctor
module_init