Module napi_h::bindgen_prelude
source · Re-exports§
pub use crate::assert_type_of;
pub use crate::check_pending_exception;
pub use crate::check_status;
pub use crate::check_status_or_throw;
pub use crate::error;
pub use crate::error;
pub use crate::type_of;
pub use crate::JsError;
pub use crate::Property;
pub use crate::PropertyAttributes;
pub use crate::Result;
pub use crate::Status;
pub use crate::Task;
pub use crate::ValueType;
pub use crate::Env;
pub use crate::JsDate as Date;
pub use crate::JsFunction;
pub use crate::sys;
Modules§
Structs§
- 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 + …)
- 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, useBufferRef
instead. - 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. - Represent
JsError
. Return this Error injs_function
, napi-rs will throw it asJsError
for you. If you want throw it asTypeError
orRangeError
, you can useJsTypeError/JsRangeError::from(Error).throw_into(env)
- 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. - A reference to a JavaScript function. It can be used to outlive the scope of the function.
- Experimental feature
- Experimental feature
- 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, useUint8ClampedArray
instead. - i64 is converted to
Number
Enums§
Traits§
- Implement a Iterator for the JavaScript Class. This feature is an experimental feature and is not yet stable.
Functions§
- Runs a future to completion This is blocking, meaning that it pauses other execution until the future is complete, only use it when it is absolutely necessary, in other places use async functions instead.
- Get
C Callback
from defined Rustfn
- Get
JsFunction
from defined Rustfn
- Spawns a future onto the Tokio runtime.
- spawn_blocking on the current Tokio runtime.
- If the feature
tokio_rt
has been enabled this will enter the runtime context and then call the provided closure. Otherwise it will just call the provided closure.
Type Aliases§
Attribute Macros§
- Marks a function or static variable as a library/executable constructor. This uses OS-specific linker sections to call a specific function at load time.