Struct napi_h::bindgen_prelude::Function
source · 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>
impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> Function<'scope, Args, Return>
sourcepub fn call(&self, args: Args) -> Result<Return>
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.
sourcepub fn apply<Context: ToNapiValue>(
&self,
this: Context,
args: Args
) -> Result<Return>
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
.
sourcepub fn create_ref(&self) -> Result<FunctionRef<Args, Return>>
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>
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>
unsafe fn from_napi_value(env: napi_env, value: napi_value) -> Result<Self>
Safety Read more
fn from_unknown(value: JsUnknown) -> Result<Self>
source§impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> NapiRaw for Function<'scope, Args, Return>
impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> NapiRaw for Function<'scope, Args, Return>
unsafe fn raw(&self) -> napi_value
source§impl<'scope, Args: JsValuesTupleIntoVec, Return: FromNapiValue> TypeName for Function<'scope, Args, Return>
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>
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>
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>
impl<'scope, Args, Return> UnwindSafe for Function<'scope, Args, Return>where
Args: UnwindSafe,
Return: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> JsValuesTupleIntoVec for Twhere
T: ToNapiValue,
impl<T> JsValuesTupleIntoVec for Twhere
T: ToNapiValue,
fn into_vec(self, env: *mut napi_env__) -> Result<Vec<*mut napi_value__>, Error>
source§impl<T> ToNapiValue for Twhere
T: NapiRaw,
impl<T> ToNapiValue for Twhere
T: NapiRaw,
source§unsafe fn to_napi_value(
_env: *mut napi_env__,
val: T
) -> Result<*mut napi_value__, Error>
unsafe fn to_napi_value( _env: *mut napi_env__, val: T ) -> Result<*mut napi_value__, Error>
Safety Read more