pub struct JsPromise<L, R>(_, _, _, _);
Implementations
This API creates a deferred object and a JavaScript promise.
pub fn spawn<T>(
env: NapiEnv,
work: impl FnMut(&mut T),
complete: impl FnMut(Self, NapiStatus, T) -> NapiResult<()>
) -> NapiResult<JsPromise<L, R>> where
T: Default,
pub fn spawn<T>(
env: NapiEnv,
work: impl FnMut(&mut T),
complete: impl FnMut(Self, NapiStatus, T) -> NapiResult<()>
) -> NapiResult<JsPromise<L, R>> where
T: Default,
Spawn a busy task in the libuv pool.
This API resolves a JavaScript promise by way of the deferred object with which it is associated. Thus, it can only be used to resolve JavaScript promises for which the corresponding deferred object is available. This effectively means that the promise must have been created using napi_create_promise() and the deferred object returned from that call must have been retained in order to be passed to this API.
The deferred object is freed upon successful completion.
This API rejects a JavaScript promise by way of the deferred object with which it is associated. Thus, it can only be used to reject JavaScript promises for which the corresponding deferred object is available. This effectively means that the promise must have been created using napi_create_promise() and the deferred object returned from that call must have been retained in order to be passed to this API.
The deferred object is freed upon successful completion.
Trait Implementations
Auto Trait Implementations
impl<L, R> RefUnwindSafe for JsPromise<L, R> where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> UnwindSafe for JsPromise<L, R> where
L: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more