neon::types::function

Struct BindOptions

source
pub struct BindOptions<'a, 'cx: 'a> { /* private fields */ }
Expand description

A builder for making a JavaScript function call like parseInt("42").

The builder methods make it convenient to assemble the call from parts:

let x: f64 = parse_int
    .bind(&mut cx)
    .arg("42")?
    .call()?;

Implementations§

source§

impl<'a, 'cx: 'a> BindOptions<'a, 'cx>

source

pub fn this<T: TryIntoJs<'cx>>(&mut self, this: T) -> NeonResult<&mut Self>

Set the value of this for the function call.

source

pub fn args<A: TryIntoArguments<'cx>>(&mut self, a: A) -> NeonResult<&mut Self>

Replaces the arguments list with the given arguments.

source

pub fn args_with<R, F>(&mut self, f: F) -> NeonResult<&mut Self>
where R: TryIntoArguments<'cx>, F: FnOnce(&mut Cx<'cx>) -> R,

Replaces the arguments list with a list computed from a closure.

source

pub fn arg<A: TryIntoJs<'cx>>(&mut self, a: A) -> NeonResult<&mut Self>

Add an argument to the arguments list.

source

pub fn arg_with<R, F>(&mut self, f: F) -> NeonResult<&mut Self>
where R: TryIntoJs<'cx>, F: FnOnce(&mut Cx<'cx>) -> R,

Add an argument to the arguments list, computed from a closure.

source

pub fn call<R: TryFromJs<'cx>>(&mut self) -> NeonResult<R>

Make the function call. If the function returns without throwing, the result value is converted to a Rust value with TryFromJs::from_js.

source

pub fn construct<R: TryFromJs<'cx>>(&mut self) -> NeonResult<R>

Make the function call as a constructor. If the function returns without throwing, the result value is converted to a Rust value with TryFromJs::from_js.

source

pub fn exec(&mut self) -> NeonResult<()>

Make the function call for side effect, discarding the result value. This method is preferable to call() when the result value isn’t needed, since it doesn’t require specifying a result type.

Auto Trait Implementations§

§

impl<'a, 'cx> Freeze for BindOptions<'a, 'cx>

§

impl<'a, 'cx> RefUnwindSafe for BindOptions<'a, 'cx>

§

impl<'a, 'cx> !Send for BindOptions<'a, 'cx>

§

impl<'a, 'cx> !Sync for BindOptions<'a, 'cx>

§

impl<'a, 'cx> Unpin for BindOptions<'a, 'cx>

§

impl<'a, 'cx> !UnwindSafe for BindOptions<'a, 'cx>

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

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>,

source§

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.