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>
impl<T> Callback<T>
pub fn new_with_args_0<R>(callback: T) -> Callback<dyn FnMut() -> R>where
T: 'static + FnMut() -> R,
R: ReturnWasmAbi + 'static,
pub fn new_with_args_1<A, R>(callback: T) -> Callback<dyn FnMut(A) -> R>
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,
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,
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,
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,
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,
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,
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§impl<T> Callback<T>where
T: ?Sized + WasmClosure + 'static,
impl<T> Callback<T>where
T: ?Sized + WasmClosure + 'static,
Sourcepub fn create<F>(t: F) -> Selfwhere
F: IntoWasmClosure<T> + 'static,
pub fn create<F>(t: F) -> Selfwhere
F: IntoWasmClosure<T> + 'static,
Create a new Callback
instance with the given closure.
Sourcepub fn set_closure<F>(&mut self, t: F)where
F: IntoWasmClosure<T> + 'static,
pub fn set_closure<F>(&mut self, t: F)where
F: IntoWasmClosure<T> + 'static,
Set closure in the given Callback
instance.
Sourcepub fn into_js<J>(&self) -> &Jwhere
J: JsCast,
pub fn into_js<J>(&self) -> &Jwhere
J: JsCast,
Obtain a wasm_bindgen::JsCast
value for this callback.
Sourcepub fn closure(&self) -> CallbackResult<Arc<Closure<T>>>
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,
impl<T> AsCallback for Callback<T>where
T: ?Sized + WasmClosure + 'static,
impl<T: ?Sized> Send for Callback<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more