pub struct ComputeContext<'a> { /* private fields */ }
Expand description

An execution context of a scope created by Context::compute_scoped().

Trait Implementations§

source§

impl<'a> Context<'a> for ComputeContext<'a>

source§

fn lock<'b>(&'b mut self) -> Lock<'_, Self>
where 'a: 'b,

Lock the JavaScript engine, returning an RAII guard that keeps the lock active as long as the guard is alive. Read more
source§

fn execute_scoped<'b, T, F>(&mut self, f: F) -> T
where F: FnOnce(ExecuteContext<'b>) -> T, 'a: 'b,

Executes a computation in a new memory management scope. Read more
source§

fn compute_scoped<'b, V, F>(&mut self, f: F) -> JsResult<'a, V>
where V: Value, F: FnOnce(ComputeContext<'b>) -> JsResult<'b, V>, 'a: 'b,

Executes a computation in a new memory management scope and computes a single result value that outlives the computation. Read more
source§

fn try_catch<T, F>(&mut self, f: F) -> Result<T, Handle<'a, JsValue>>
where F: FnOnce(&mut Self) -> NeonResult<T>,

source§

fn boolean(&mut self, b: bool) -> Handle<'a, JsBoolean>

Convenience method for creating a JsBoolean value.
source§

fn number<T: Into<f64>>(&mut self, x: T) -> Handle<'a, JsNumber>

Convenience method for creating a JsNumber value.
source§

fn string<S: AsRef<str>>(&mut self, s: S) -> Handle<'a, JsString>

Convenience method for creating a JsString value. Read more
source§

fn try_string<S: AsRef<str>>(&mut self, s: S) -> StringResult<'a>

Convenience method for creating a JsString value. Read more
source§

fn null(&mut self) -> Handle<'a, JsNull>

Convenience method for creating a JsNull value.
source§

fn undefined(&mut self) -> Handle<'a, JsUndefined>

Convenience method for creating a JsUndefined value.
source§

fn empty_object(&mut self) -> Handle<'a, JsObject>

Convenience method for creating an empty JsObject value.
source§

fn empty_array(&mut self) -> Handle<'a, JsArray>

Convenience method for creating an empty JsArray value.
source§

fn array_buffer(&mut self, size: usize) -> JsResult<'a, JsArrayBuffer>

Convenience method for creating an empty JsArrayBuffer value.
source§

fn buffer(&mut self, size: usize) -> JsResult<'a, JsBuffer>

Convenience method for creating an empty JsBuffer value.
source§

fn date( &mut self, value: impl Into<f64> ) -> Result<Handle<'a, JsDate>, DateError>

Available on crate feature napi-5 only.
Convenience method for creating a JsDate value.
source§

fn global<T: Value>(&mut self, name: &str) -> JsResult<'a, T>

Convenience method for looking up a global property by name. Read more
source§

fn global_object(&mut self) -> Handle<'a, JsObject>

Produces a handle to the JavaScript global object.
source§

fn throw<T: Value, U>(&mut self, v: Handle<'_, T>) -> NeonResult<U>

Throws a JS value.
source§

fn error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>

Creates a direct instance of the Error class.
source§

fn type_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>

Creates an instance of the TypeError class.
source§

fn range_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>

Creates an instance of the RangeError class.
source§

fn throw_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>

Throws a direct instance of the Error class.
source§

fn throw_type_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>

Throws an instance of the TypeError class.
source§

fn throw_range_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>

Throws an instance of the RangeError class.
source§

fn boxed<U: Finalize + 'static>(&mut self, v: U) -> Handle<'a, JsBox<U>>

Convenience method for wrapping a value in a JsBox. Read more
source§

fn channel(&mut self) -> Channel

Available on crate feature napi-4 only.
Returns an unbounded channel for scheduling events to be executed on the JavaScript thread. Read more
source§

fn promise(&mut self) -> (Deferred, Handle<'a, JsPromise>)

Creates a Deferred and JsPromise pair. The Deferred handle can be used to resolve or reject the JsPromise. Read more
source§

fn task<'cx, O, E>(&'cx mut self, execute: E) -> TaskBuilder<'_, Self, E>
where O: Send + 'static, E: FnOnce() -> O + Send + 'static, 'a: 'cx,

Creates a TaskBuilder which can be used to schedule the execute callback to asynchronously execute on the Node worker pool. Read more
source§

fn to_raw(&self) -> Env

Available on crate feature sys only.
Gets the raw sys::Env for usage with Node-API.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for ComputeContext<'a>

§

impl<'a> !Send for ComputeContext<'a>

§

impl<'a> !Sync for ComputeContext<'a>

§

impl<'a> Unpin for ComputeContext<'a>

§

impl<'a> UnwindSafe for ComputeContext<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.