Struct Callback

Source
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) -> Self
where 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) -> &J
where 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 JsValue
where 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> Freeze for Callback<T>
where T: ?Sized,

§

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

§

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

§

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

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> Any for T
where T: Any,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

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 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more