pub struct Callback<T: ?Sized> { /* private fields */ }
Expand description

Callback is a struct that owns a given Rust closure meant to be bound to JavaScript as a callback.

Implementations§

source§

impl<T> Callback<T>

source

pub fn new_with_args_0<R>(callback: T) -> Callback<dyn FnMut() -> R>where T: 'static + FnMut() -> R, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_1<A, R>(callback: T) -> Callback<dyn FnMut(A) -> R>where T: 'static + FnMut(A) -> R, A: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_2<A, B, R>(callback: T) -> Callback<dyn FnMut(A, B) -> R>where T: 'static + FnMut(A, B) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_3<A, B, C, R>( callback: T ) -> Callback<dyn FnMut(A, B, C) -> R>where T: 'static + FnMut(A, B, C) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_4<A, B, C, D, R>( callback: T ) -> Callback<dyn FnMut(A, B, C, D) -> R>where T: 'static + FnMut(A, B, C, D) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, D: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_5<A, B, C, D, E, R>( callback: T ) -> Callback<dyn FnMut(A, B, C, D, E) -> R>where T: 'static + FnMut(A, B, C, D, E) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, D: FromWasmAbi + 'static, E: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_6<A, B, C, D, E, F, R>( callback: T ) -> Callback<dyn FnMut(A, B, C, D, E, F) -> R>where T: 'static + FnMut(A, B, C, D, E, F) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, D: FromWasmAbi + 'static, E: FromWasmAbi + 'static, F: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_7<A, B, C, D, E, F, G, R>( callback: T ) -> Callback<dyn FnMut(A, B, C, D, E, F, G) -> R>where T: 'static + FnMut(A, B, C, D, E, F, G) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, D: FromWasmAbi + 'static, E: FromWasmAbi + 'static, F: FromWasmAbi + 'static, G: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new_with_args_8<A, B, C, D, E, F, G, H, R>( callback: T ) -> Callback<dyn FnMut(A, B, C, D, E, F, G, H) -> R>where T: 'static + FnMut(A, B, C, D, E, F, G, H) -> R, A: FromWasmAbi + 'static, B: FromWasmAbi + 'static, C: FromWasmAbi + 'static, D: FromWasmAbi + 'static, E: FromWasmAbi + 'static, F: FromWasmAbi + 'static, G: FromWasmAbi + 'static, H: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

source

pub fn new<A, R>(callback: T) -> Callback<dyn FnMut(A) -> R>where T: 'static + FnMut(A) -> R, A: FromWasmAbi + 'static, R: ReturnWasmAbi + 'static,

Create a new Callback instance with the given closure.

source§

impl<T> Callback<T>where T: ?Sized + WasmClosure + 'static,

source

pub fn create<F>(t: F) -> Selfwhere F: IntoWasmClosure<T> + 'static,

Create a new Callback instance with the given closure.

source

pub fn set_closure<F>(&mut self, t: F)where F: IntoWasmClosure<T> + 'static,

Set closure in the given Callback instance.

source

pub fn into_js<J>(&self) -> &Jwhere J: JsCast,

Obtain a wasm_bindgen::JsCast value for this callback.

source

pub fn closure(&self) -> CallbackResult<Arc<Closure<T>>>

Obtain an std::sync::Arc of the given closure. Returns CallbackError::ClosureNotInitialized if the closure is None.

Trait Implementations§

source§

impl<T> AsCallback for Callback<T>where T: ?Sized + WasmClosure + 'static,

source§

impl<T> AsRef<Function> for Callback<T>where T: ?Sized + WasmClosure + 'static,

source§

fn as_ref(&self) -> &Function

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

impl<T> AsRef<JsValue> for Callback<T>where T: ?Sized + WasmClosure + 'static,

source§

fn as_ref(&self) -> &JsValue

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

impl<T: ?Sized> Clone for Callback<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: ?Sized> Debug for Callback<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for Callback<T>where T: ?Sized + WasmClosure + 'static,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> From<Callback<T>> for JsValuewhere T: ?Sized + WasmClosure + 'static,

source§

fn from(callback: Callback<T>) -> Self

Converts to this type from the input type.
source§

impl<T: ?Sized> Send for Callback<T>

source§

impl<T: ?Sized> Sync for Callback<T>

Auto Trait Implementations§

§

impl<T: ?Sized> RefUnwindSafe for Callback<T>

§

impl<T: ?Sized> Unpin for Callback<T>

§

impl<T: ?Sized> UnwindSafe for Callback<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T, Global>) -> Arc<dyn Any + Send + Sync, Global>

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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V