pub struct JsPromise<L, R>(_, _, _, _);
Implementations
sourceimpl<L: NapiValueT, R: NapiValueT> JsPromise<L, R>
impl<L: NapiValueT, R: NapiValueT> JsPromise<L, R>
pub fn env(&self) -> NapiEnv
pub fn raw(&self) -> napi_value
pub fn value(&self) -> JsValue
sourcepub fn new(env: NapiEnv) -> NapiResult<JsPromise<L, R>>
pub fn new(env: NapiEnv) -> NapiResult<JsPromise<L, R>>
This API creates a deferred object and a JavaScript promise.
sourcepub fn spawn<T>(
env: NapiEnv,
work: impl FnMut(&mut T) + Send,
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) + Send,
complete: impl FnMut(Self, NapiStatus, T) -> NapiResult<()>
) -> NapiResult<JsPromise<L, R>> where
T: Default,
Spawn a busy task in the libuv pool.
sourcepub fn resolve(&self, resolution: L) -> NapiResult<()>
pub fn resolve(&self, resolution: L) -> NapiResult<()>
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.
sourcepub fn reject(&self, rejection: R) -> NapiResult<()>
pub fn reject(&self, rejection: R) -> NapiResult<()>
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
sourceimpl<L: NapiValueT, R: NapiValueT> NapiValueCheck for JsPromise<L, R>
impl<L: NapiValueT, R: NapiValueT> NapiValueCheck for JsPromise<L, R>
fn check(&self) -> NapiResult<bool>
Auto Trait Implementations
impl<L, R> RefUnwindSafe for JsPromise<L, R> where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> !Send for JsPromise<L, R>
impl<L, R> !Sync for JsPromise<L, R>
impl<L, R> Unpin for JsPromise<L, R> where
L: Unpin,
R: Unpin,
impl<L, R> UnwindSafe for JsPromise<L, R> where
L: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more