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

An execution context of a function call.

The type parameter T is the type of the this-binding.

Implementations§

Indicates whether the function was called with new.

Indicates the number of arguments that were passed to the function.

Indicates if no arguments were passed to the function.

Produces the ith argument, or None if i is greater than or equal to self.len().

Produces the ith argument and casts it to the type V, or throws an exception if i is greater than or equal to self.len() or cannot be cast to V.

Produces a handle to the this-binding and attempts to downcast as a specific type. Equivalent to calling cx.this_value().downcast_or_throw(&mut cx).

Throws an exception if the value is a different type.

Produces a handle to the function’s this-binding.

Trait Implementations§

Lock the JavaScript engine, returning an RAII guard that keeps the lock active as long as the guard is alive. Read more
Executes a computation in a new memory management scope. Read more
Executes a computation in a new memory management scope and computes a single result value that outlives the computation. Read more
Convenience method for creating a JsBoolean value.
Convenience method for creating a JsNumber value.
Convenience method for creating a JsString value. Read more
Convenience method for creating a JsString value. Read more
Convenience method for creating a JsNull value.
Convenience method for creating a JsUndefined value.
Convenience method for creating an empty JsObject value.
Convenience method for creating an empty JsArray value.
Convenience method for creating an empty JsArrayBuffer value.
Convenience method for creating an empty JsBuffer value.
Available on crate feature napi-5 only.
Convenience method for creating a JsDate value.
Produces a handle to the JavaScript global object.
Throws a JS value.
Creates a direct instance of the Error class.
Creates an instance of the TypeError class.
Creates an instance of the RangeError class.
Throws a direct instance of the Error class.
Throws an instance of the TypeError class.
Throws an instance of the RangeError class.
Convenience method for wrapping a value in a JsBox. Read more
Available on crate feature napi-4 only.
Returns an unbounded channel for scheduling events to be executed on the JavaScript thread. Read more
Creates a Deferred and JsPromise pair. The Deferred handle can be used to resolve or reject the JsPromise. Read more
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§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.