#[repr(transparent)]
pub struct Async<F>(pub F);
Available on crate feature futures only.
Expand description

The wrapper for async functons

This type wraps returned future into Promised

// Inorder to conver to a javascript promise the future must return a `Result`.
async fn my_func() -> Result<()> { Ok(()) }
let func = Function::new(ctx, Async(my_func));

Tuple Fields§

§0: F

Trait Implementations§

source§

impl<'js, F, Fut, R> AsFunction<'js, (), Promised<R>> for Async<F>where F: Fn() -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R> AsFunction<'js, (), Promised<R>> for Async<MutFn<F>>where F: FnMut() -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R> AsFunction<'js, (), Promised<R>> for Async<OnceFn<F>>where F: FnOnce() -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A> AsFunction<'js, (A,), Promised<R>> for Async<F>where F: Fn(A) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A> AsFunction<'js, (A,), Promised<R>> for Async<MutFn<F>>where F: FnMut(A) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A> AsFunction<'js, (A,), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B> AsFunction<'js, (A, B), Promised<R>> for Async<F>where F: Fn(A, B) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B> AsFunction<'js, (A, B), Promised<R>> for Async<MutFn<F>>where F: FnMut(A, B) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B> AsFunction<'js, (A, B), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A, B) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D> AsFunction<'js, (A, B, D), Promised<R>> for Async<F>where F: Fn(A, B, D) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D> AsFunction<'js, (A, B, D), Promised<R>> for Async<MutFn<F>>where F: FnMut(A, B, D) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D> AsFunction<'js, (A, B, D), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A, B, D) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E> AsFunction<'js, (A, B, D, E), Promised<R>> for Async<F>where F: Fn(A, B, D, E) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E> AsFunction<'js, (A, B, D, E), Promised<R>> for Async<MutFn<F>>where F: FnMut(A, B, D, E) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E> AsFunction<'js, (A, B, D, E), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A, B, D, E) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G> AsFunction<'js, (A, B, D, E, G), Promised<R>> for Async<F>where F: Fn(A, B, D, E, G) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G> AsFunction<'js, (A, B, D, E, G), Promised<R>> for Async<MutFn<F>>where F: FnMut(A, B, D, E, G) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G> AsFunction<'js, (A, B, D, E, G), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A, B, D, E, G) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G, H> AsFunction<'js, (A, B, D, E, G, H), Promised<R>> for Async<F>where F: Fn(A, B, D, E, G, H) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>, H: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G, H> AsFunction<'js, (A, B, D, E, G, H), Promised<R>> for Async<MutFn<F>>where F: FnMut(A, B, D, E, G, H) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>, H: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, A, B, D, E, G, H> AsFunction<'js, (A, B, D, E, G, H), Promised<R>> for Async<OnceFn<F>>where F: FnOnce(A, B, D, E, G, H) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>, H: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T> AsFunction<'js, (T,), Promised<R>> for Async<Method<F>>where F: Fn(T) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A> AsFunction<'js, (T, A), Promised<R>> for Async<Method<F>>where F: Fn(T, A) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A, B> AsFunction<'js, (T, A, B), Promised<R>> for Async<Method<F>>where F: Fn(T, A, B) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A, B, D> AsFunction<'js, (T, A, B, D), Promised<R>> for Async<Method<F>>where F: Fn(T, A, B, D) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A, B, D, E> AsFunction<'js, (T, A, B, D, E), Promised<R>> for Async<Method<F>>where F: Fn(T, A, B, D, E) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A, B, D, E, G> AsFunction<'js, (T, A, B, D, E, G), Promised<R>> for Async<Method<F>>where F: Fn(T, A, B, D, E, G) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, Fut, R, T, A, B, D, E, G, H> AsFunction<'js, (T, A, B, D, E, G, H), Promised<R>> for Async<Method<F>>where F: Fn(T, A, B, D, E, G, H) -> Fut + 'js, Fut: Future<Output = Result<R>> + 'js, R: IntoJs<'js> + 'js, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>, H: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<F> AsRef<F> for Async<F>

source§

fn as_ref(&self) -> &F

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<F> Deref for Async<F>

§

type Target = F

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Async<F>where F: RefUnwindSafe,

§

impl<F> Send for Async<F>where F: Send,

§

impl<F> Sync for Async<F>where F: Sync,

§

impl<F> Unpin for Async<F>where F: Unpin,

§

impl<F> UnwindSafe for Async<F>where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> ParallelSend for T