pub trait TryFromJsValue: Sized {
type Error;
// Required method
fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>;
}
Expand description
TryFromJsValue
is a trait for converting a JavaScript value (JsValue
)
into a Rust type. It is used by the wasm_bindgen
proc-macro to allow conversion to user types.
Types implementing this trait must specify their conversion logic from
JsValue
to the Rust type, handling any potential errors that may occur
during the conversion process.
§⚠️ Unstable
This is part of the internal convert
module, no
stability guarantees are provided. Use at your own risk. See its
documentation for more details.
Required Associated Types§
Required Methods§
sourcefn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>
fn try_from_js_value(value: JsValue) -> Result<Self, Self::Error>
Performs the conversion.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.