Module workflow_wasm::convert
source · Expand description
WASM bindgen casting and utility functions.
This module provides a CastFromJs
trait and derive macro
that allows for easy casting of JavaScript objects into Rust.
The secondary goal of this module is to provide the ability
to dynamically interpret user-supplied JavaScript data that
instead of a Rust object may container other data that can
be used (interpreted) to create a Rust object.
To accommodate this a TryCastFromJs
trait is provided
where user needs to implement try_cast_from
function that
can attempt to cast a JsValue into a Rust object or interpret
the source data and create a temporary struct owned by by the
Cast
enum.
Structs§
Enums§
- A wrapper for a Rust object that can be either a reference or a value. This wrapper is used to carry a Rust (WASM ABI) reference provided by
wasm_bindgen
, but at the same time allows creation of a temporary object that can be created by interpreting the source user-supplied data.Cast
then providesCast::as_ref()
to obtain the internally held reference andCast::into_owned()
where the latter will consume the value or clone the reference.
Traits§
- A trait for borrowing data.
CastFromJs
trait is automatically implemented by deriving theCastFromJs
derive macro. This trait provides functions for accessing Rust references from the WASM ABI.- Used for immutable dereferencing operations, like
*v
. TryCastFromJs
trait is meant to be implemented by the developer on any struct implementingCastFromJs
trait. This trait provides a way to attempt to cast a JsValue into a Rust object or interpret the source data and create a temporary struct owned by by theCast
.
Functions§
- Configuration for the WASM32 bindings runtime interface. @see {@link IWASM32BindingsConfig} @category General
- Create a reference to a Rust object from a WASM ABI.
- Create a reference to a Rust object from a WASM ABI. Returns None is the supplied value is
null
orundefined
, otherwise attempts to cast the object.