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.