Skip to main content

CastFromJs

Trait CastFromJs 

Source
pub trait CastFromJs
where Self: Sized + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<Self>>> + LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<Self>>>,
{ // Required methods fn try_ref_from_js_value<'a, R>( js_value: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error> where R: AsRef<JsValue> + 'a; fn try_long_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as LongRefFromWasmAbi>::Anchor, Error> where R: AsRef<JsValue> + 'a; // Provided methods fn try_ref_from_js_value_as_cast<'a, R>( js_value: &'a R, ) -> Result<Cast<'a, Self>, Error> where R: AsRef<JsValue> + 'a { ... } fn try_long_ref_from_js_value_as_cast<'a, R>( js: &'a R, ) -> Result<Cast<'a, Self>, Error> where R: AsRef<JsValue> + 'a { ... } }
Expand description

CastFromJs trait is automatically implemented by deriving the CastFromJs derive macro. This trait provides functions for accessing Rust references from the WASM ABI.

Required Methods§

Source

fn try_ref_from_js_value<'a, R>( js_value: &'a R, ) -> Result<<Self as RefFromWasmAbi>::Anchor, Error>
where R: AsRef<JsValue> + 'a,

Obtain safe reference from JsValue

Source

fn try_long_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Self as LongRefFromWasmAbi>::Anchor, Error>
where R: AsRef<JsValue> + 'a,

Obtain safe long reference from JsValue

Provided Methods§

Source

fn try_ref_from_js_value_as_cast<'a, R>( js_value: &'a R, ) -> Result<Cast<'a, Self>, Error>
where R: AsRef<JsValue> + 'a,

Obtain a safe reference from a JsValue, wrapped in a Cast::Ref.

Source

fn try_long_ref_from_js_value_as_cast<'a, R>( js: &'a R, ) -> Result<Cast<'a, Self>, Error>
where R: AsRef<JsValue> + 'a,

Obtain a safe long-lived reference from a JsValue, wrapped in a Cast::LongRef.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§