[][src]Struct napi::JsFunction

pub struct JsFunction(_);

Implementations

impl JsFunction[src]

See Working with JavaScript Functions.

Example:

use napi::{JsFunction, CallContext, JsNull, Result};

#[js_function(1)]
pub fn call_function(ctx: CallContext) -> Result<JsNull> {
  let js_func = ctx.get::<JsFunction>(0)?;
  let js_string = ctx.env.create_string("hello".as_ref())?.into_unknown()?;
  js_func.call(None, &[js_string])?;
  Ok(ctx.env.get_null()?)
}

pub fn call(
    &self,
    this: Option<&JsObject>,
    args: &[JsUnknown]
) -> Result<JsUnknown>
[src]

impl JsFunction[src]

impl JsFunction[src]

pub fn from_raw_unchecked(env: napi_env, value: napi_value) -> Self[src]

Trait Implementations

impl Debug for JsFunction[src]

impl NapiValue for JsFunction[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.