Struct neon::context::ComputeContext
source · [−]pub struct ComputeContext<'a, 'outer> { /* private fields */ }
Expand description
An execution context of a scope created by Context::compute_scoped()
.
Trait Implementations
sourceimpl<'a, 'b> Context<'a> for ComputeContext<'a, 'b>
impl<'a, 'b> Context<'a> for ComputeContext<'a, 'b>
sourcefn lock<'b>(&'b mut self) -> Lock<'_, Self> where
'a: 'b,
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
sourcefn execute_scoped<T, F>(&mut self, f: F) -> T where
F: for<'b> FnOnce(ExecuteContext<'b>) -> T,
fn execute_scoped<T, F>(&mut self, f: F) -> T where
F: for<'b> FnOnce(ExecuteContext<'b>) -> T,
Executes a computation in a new memory management scope. Read more
sourcefn compute_scoped<V, F>(&mut self, f: F) -> JsResult<'a, V> where
V: Value,
F: for<'b, 'c> FnOnce(ComputeContext<'b, 'c>) -> JsResult<'b, V>,
fn compute_scoped<V, F>(&mut self, f: F) -> JsResult<'a, V> where
V: Value,
F: for<'b, 'c> FnOnce(ComputeContext<'b, 'c>) -> JsResult<'b, V>,
Executes a computation in a new memory management scope and computes a single result value that outlives the computation. Read more
sourcefn try_catch<T, F>(&mut self, f: F) -> Result<T, Handle<'a, JsValue>> where
F: FnOnce(&mut Self) -> NeonResult<T>,
fn try_catch<T, F>(&mut self, f: F) -> Result<T, Handle<'a, JsValue>> where
F: FnOnce(&mut Self) -> NeonResult<T>,
try-catch-api
only.sourcefn boolean(&mut self, b: bool) -> Handle<'a, JsBoolean>
fn boolean(&mut self, b: bool) -> Handle<'a, JsBoolean>
Convenience method for creating a JsBoolean
value.
sourcefn number<T: Into<f64>>(&mut self, x: T) -> Handle<'a, JsNumber>
fn number<T: Into<f64>>(&mut self, x: T) -> Handle<'a, JsNumber>
Convenience method for creating a JsNumber
value.
sourcefn string<S: AsRef<str>>(&mut self, s: S) -> Handle<'a, JsString>
fn string<S: AsRef<str>>(&mut self, s: S) -> Handle<'a, JsString>
Convenience method for creating a JsString
value. Read more
sourcefn try_string<S: AsRef<str>>(&mut self, s: S) -> StringResult<'a>
fn try_string<S: AsRef<str>>(&mut self, s: S) -> StringResult<'a>
Convenience method for creating a JsString
value. Read more
sourcefn undefined(&mut self) -> Handle<'a, JsUndefined>
fn undefined(&mut self) -> Handle<'a, JsUndefined>
Convenience method for creating a JsUndefined
value.
sourcefn empty_object(&mut self) -> Handle<'a, JsObject>
fn empty_object(&mut self) -> Handle<'a, JsObject>
Convenience method for creating an empty JsObject
value.
sourcefn empty_array(&mut self) -> Handle<'a, JsArray>
fn empty_array(&mut self) -> Handle<'a, JsArray>
Convenience method for creating an empty JsArray
value.
sourcefn array_buffer(&mut self, size: usize) -> JsResult<'a, JsArrayBuffer>
fn array_buffer(&mut self, size: usize) -> JsResult<'a, JsArrayBuffer>
Convenience method for creating an empty JsArrayBuffer
value.
sourcefn buffer(&mut self, size: usize) -> JsResult<'a, JsBuffer>
fn buffer(&mut self, size: usize) -> JsResult<'a, JsBuffer>
Convenience method for creating an empty JsBuffer
value.
sourcefn date(
&mut self,
value: impl Into<f64>
) -> Result<Handle<'a, JsDate>, DateError>
fn date(
&mut self,
value: impl Into<f64>
) -> Result<Handle<'a, JsDate>, DateError>
napi-5
only.Convenience method for creating a JsDate
value.
sourcefn global(&mut self) -> Handle<'a, JsObject>
fn global(&mut self) -> Handle<'a, JsObject>
Produces a handle to the JavaScript global object.
sourcefn throw<T: Value, U>(&mut self, v: Handle<'_, T>) -> NeonResult<U>
fn throw<T: Value, U>(&mut self, v: Handle<'_, T>) -> NeonResult<U>
Throws a JS value.
sourcefn error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
fn error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
Creates a direct instance of the Error
class.
sourcefn type_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
fn type_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
Creates an instance of the TypeError
class.
sourcefn range_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
fn range_error<S: AsRef<str>>(&mut self, msg: S) -> JsResult<'a, JsError>
Creates an instance of the RangeError
class.
sourcefn throw_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
fn throw_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
Throws a direct instance of the Error
class.
sourcefn throw_type_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
fn throw_type_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
Throws an instance of the TypeError
class.
sourcefn throw_range_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
fn throw_range_error<S: AsRef<str>, T>(&mut self, msg: S) -> NeonResult<T>
Throws an instance of the RangeError
class.
sourcefn boxed<U: Finalize + Send + 'static>(&mut self, v: U) -> Handle<'a, JsBox<U>>
fn boxed<U: Finalize + Send + 'static>(&mut self, v: U) -> Handle<'a, JsBox<U>>
Convenience method for wrapping a value in a JsBox
. Read more
sourcefn channel(&mut self) -> Channel
fn channel(&mut self) -> Channel
napi-4
and channel-api
only.Returns an unbounded channel for scheduling events to be executed on the JavaScript thread. Read more
sourcefn promise(&mut self) -> (Deferred, Handle<'a, JsPromise>)
fn promise(&mut self) -> (Deferred, Handle<'a, JsPromise>)
promise-api
only.sourcefn task<'cx, O, E>(&'cx mut self, execute: E) -> TaskBuilder<'_, Self, E> where
'a: 'cx,
O: Send + 'static,
E: FnOnce() -> O + Send + 'static,
fn task<'cx, O, E>(&'cx mut self, execute: E) -> TaskBuilder<'_, Self, E> where
'a: 'cx,
O: Send + 'static,
E: FnOnce() -> O + Send + 'static,
task-api
only.Creates a TaskBuilder
which can be used to schedule the execute
callback to asynchronously execute on the
Node worker pool. Read more
Auto Trait Implementations
impl<'a, 'outer> !RefUnwindSafe for ComputeContext<'a, 'outer>
impl<'a, 'outer> !Send for ComputeContext<'a, 'outer>
impl<'a, 'outer> !Sync for ComputeContext<'a, 'outer>
impl<'a, 'outer> Unpin for ComputeContext<'a, 'outer>
impl<'a, 'outer> !UnwindSafe for ComputeContext<'a, 'outer>
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