from_js_ref 0.1.0

Trait for converting from JS interface reference wrappers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pub trait FromJsRef: Sized {
    type JsRef: wasm_bindgen::JsCast;
    fn from_js_ref(castable: &Self::JsRef) -> Self;
}

pub trait JsDeref<T: FromJsRef> {
    fn js_deref(&self) -> T;
}

impl<T: FromJsRef> JsDeref<T> for T::JsRef {
    fn js_deref(&self) -> T {
        T::from_js_ref(self)
    }
}