pub trait FromJsRef: Sized {
type JsRef: JsCast;
// Required method
fn from_js_ref(castable: &Self::JsRef) -> Self;
// Provided method
fn try_from_js_value(js_value: &JsValue) -> Option<Self> { ... }
}Expand description
A trait for converting from a JS reference type to a Rust type.
Required Associated Types§
Required Methods§
Sourcefn from_js_ref(castable: &Self::JsRef) -> Self
fn from_js_ref(castable: &Self::JsRef) -> Self
Converts from a JS reference type to the Rust type.
Provided Methods§
Sourcefn try_from_js_value(js_value: &JsValue) -> Option<Self>
fn try_from_js_value(js_value: &JsValue) -> Option<Self>
Attempts to convert from a JsValue to the Rust type by going through the JS reference type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".