Skip to main content

FromJsRef

Trait FromJsRef 

Source
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§

Source

fn from_js_ref(castable: &Self::JsRef) -> Self

Converts from a JS reference type to the Rust type.

Provided Methods§

Source

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".

Implementors§