pub enum Cast<'a, T>where
T: RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + 'a,{
Ref {
anchor: <T as RefFromWasmAbi>::Anchor,
},
OwnedRef {
js_value: Option<JsValue>,
anchor: Option<<T as RefFromWasmAbi>::Anchor>,
},
LongRef {
anchor: <T as LongRefFromWasmAbi>::Anchor,
},
Value {
value: Option<T>,
},
_Unreachable(Infallible, &'a PhantomData<T>),
}Expand description
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 provides Cast::as_ref() to obtain the internally held
reference and Cast::into_owned() where the latter will consume the
value or clone the reference.
Variants§
Ref
A borrowed reference to a Rust object obtained from the WASM ABI.
Fields
anchor: <T as RefFromWasmAbi>::AnchorAnchor keeping the borrowed reference alive.
OwnedRef
A reference that also owns (captures) the source JsValue keeping it alive.
Fields
anchor: Option<<T as RefFromWasmAbi>::Anchor>Anchor keeping the borrowed reference alive.
LongRef
A long-lived reference to a Rust object obtained from the WASM ABI.
Fields
anchor: <T as LongRefFromWasmAbi>::AnchorAnchor keeping the long-lived reference alive.
Value
An owned value, typically created by interpreting user-supplied data.
_Unreachable(Infallible, &'a PhantomData<T>)
Uninhabited variant carrying the lifetime parameter; never constructed.
Implementations§
Source§impl<T> Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + Clone,
impl<T> Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + Clone,
Sourcepub fn into_owned(self) -> T
pub fn into_owned(self) -> T
Sourcepub fn value(value: T) -> Cast<'_, T>
pub fn value(value: T) -> Cast<'_, T>
Construct a Cast::Value holding an owned value.
Trait Implementations§
Source§impl<T> AsRef<T> for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
impl<T> AsRef<T> for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
Source§impl<T> Deref for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + Deref,
impl<T> Deref for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + Deref,
Source§impl<T> Drop for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
impl<T> Drop for Cast<'_, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
Source§impl<'a, T> From<T> for Cast<'a, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
Cast T value (struct) into Cast<T>
impl<'a, T> From<T> for Cast<'a, T>where
T: LongRefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>> + RefFromWasmAbi<Abi = WasmPtr<WasmRefCell<T>>>,
Cast T value (struct) into Cast<T>