use wasm_bindgen::prelude::*; mod glue { use super::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen] pub type Response; #[wasm_bindgen(method, catch, getter)] pub fn webSocket(this: &Response) -> Result, JsValue>; #[wasm_bindgen(method, catch, getter)] pub fn cf(this: &Response) -> Result, JsValue>; } } pub trait ResponseExt { /// Getter for the `webSocket` field of this object. fn websocket(&self) -> Option; /// Getter for the `cf` field of this object. fn cf(&self) -> Option; } impl ResponseExt for web_sys::Response { fn websocket(&self) -> Option { self.unchecked_ref::() .webSocket() .expect("read response.webSocket") } fn cf(&self) -> Option { self.unchecked_ref::() .cf() .expect("read response.cf") } }