pub unsafe trait DowncastJS: Sized + FromWasmAbi<Abi = u32> + RefFromWasmAbi<Abi = u32> {
    fn token() -> &'static DowncastToken;

    fn downcast_js(value: JsValue) -> Result<Self, JsValue> { ... }
    fn downcast_js_ref(value: &JsValue) -> Option<Self::Anchor> { ... }
}
Expand description

Cast a Rust wrapper class that was generated by #[wasm_bindgen] back to the underlying Rust type.

This is a workaround for rustwasm/wasm-bindgen#2231 that is robust with respect to minification (something other solutions can’t handle).

Safety

This assumes the wrapper class has a static __wbgd_downcast_symbol method which returns the same DowncastToken as DowncastJS::token(). Each trait implementation.

Users should use the custom derive rather than implement this manually.

Required Methods§

Provided Methods§

Implementors§