pub struct Function<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> { /* private fields */ }
Expand description

A JavaScript function. It can only live in the scope of a function call. If you want to use it outside the scope of a function call, you can turn it into a reference. By calling the create_ref method.

Implementations§

source§

impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> Function<'scope, Args, Return>

source

pub fn call(&self, args: Args) -> Result<Return>

Call the JavaScript function. this in the JavaScript function will be undefined. If you want to specify this, you can use the apply method.

source

pub fn apply<Context: ToNapiValue>( &self, this: Context, args: Args ) -> Result<Return>

Call the JavaScript function. this in the JavaScript function will be the provided this.

source

pub fn create_ref(&self) -> Result<FunctionRef<Args, Return>>

Create a reference to the JavaScript function.

Trait Implementations§

source§

impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> FromNapiValue for Function<'scope, Args, Return>

source§

unsafe fn from_napi_value(env: napi_env, value: napi_value) -> Result<Self>

Safety Read more
source§

fn from_unknown(value: JsUnknown) -> Result<Self>

source§

impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> NapiRaw for Function<'scope, Args, Return>

source§

unsafe fn raw(&self) -> napi_value

source§

impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> TypeName for Function<'scope, Args, Return>

source§

impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> ValidateNapiValue for Function<'scope, Args, Return>

source§

unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>

Safety Read more

Auto Trait Implementations§

§

impl<'scope, Args, Return> Freeze for Function<'scope, Args, Return>

§

impl<'scope, Args, Return> RefUnwindSafe for Function<'scope, Args, Return>
where Args: RefUnwindSafe, Return: RefUnwindSafe,

§

impl<'scope, Args, Return> !Send for Function<'scope, Args, Return>

§

impl<'scope, Args, Return> !Sync for Function<'scope, Args, Return>

§

impl<'scope, Args, Return> Unpin for Function<'scope, Args, Return>
where Args: Unpin, Return: Unpin,

§

impl<'scope, Args, Return> UnwindSafe for Function<'scope, Args, Return>
where Args: UnwindSafe, Return: UnwindSafe,

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> JsValuesTupleIntoVec for T
where T: ToNapiValue,

source§

impl<T> ToNapiValue for T
where T: NapiRaw,

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.