use tsify::Tsify; #[tsify(into_wasm_abi, from_wasm_abi)] pub struct GenericStruct { x: T, } #[automatically_derived] const _: () = { extern crate serde as _serde; use tsify::Tsify; use wasm_bindgen::{ convert::{FromWasmAbi, IntoWasmAbi, OptionFromWasmAbi, OptionIntoWasmAbi}, describe::WasmDescribe, prelude::*, }; #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "GenericStruct")] pub type JsType; } impl Tsify for GenericStruct { type JsType = JsType; const DECL: &'static str = "export interface GenericStruct {\n x: T;\n}"; } #[wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = "export interface GenericStruct {\n x: T;\n}"; impl WasmDescribe for GenericStruct { #[inline] fn describe() { ::JsType::describe() } } impl IntoWasmAbi for GenericStruct where Self: _serde::Serialize, { type Abi = ::Abi; #[inline] fn into_abi(self) -> Self::Abi { self.into_js().unwrap_throw().into_abi() } } impl OptionIntoWasmAbi for GenericStruct where Self: _serde::Serialize, { #[inline] fn none() -> Self::Abi { ::none() } } impl FromWasmAbi for GenericStruct where Self: _serde::de::DeserializeOwned, { type Abi = ::Abi; #[inline] unsafe fn from_abi(js: Self::Abi) -> Self { let result = Self::from_js(&JsType::from_abi(js)); if let Err(err) = result { wasm_bindgen::throw_str(err.to_string().as_ref()); } result.unwrap_throw() } } impl OptionFromWasmAbi for GenericStruct where Self: _serde::de::DeserializeOwned, { #[inline] fn is_none(js: &Self::Abi) -> bool { ::is_none(js) } } }; #[tsify(into_wasm_abi, from_wasm_abi)] pub struct GenericNewtype(T); #[automatically_derived] const _: () = { extern crate serde as _serde; use tsify::Tsify; use wasm_bindgen::{ convert::{FromWasmAbi, IntoWasmAbi, OptionFromWasmAbi, OptionIntoWasmAbi}, describe::WasmDescribe, prelude::*, }; #[wasm_bindgen] extern "C" { #[wasm_bindgen(typescript_type = "GenericNewtype")] pub type JsType; } impl Tsify for GenericNewtype { type JsType = JsType; const DECL: &'static str = "export type GenericNewtype = T;"; } #[wasm_bindgen(typescript_custom_section)] const TS_APPEND_CONTENT: &'static str = "export type GenericNewtype = T;"; impl WasmDescribe for GenericNewtype { #[inline] fn describe() { ::JsType::describe() } } impl IntoWasmAbi for GenericNewtype where Self: _serde::Serialize, { type Abi = ::Abi; #[inline] fn into_abi(self) -> Self::Abi { self.into_js().unwrap_throw().into_abi() } } impl OptionIntoWasmAbi for GenericNewtype where Self: _serde::Serialize, { #[inline] fn none() -> Self::Abi { ::none() } } impl FromWasmAbi for GenericNewtype where Self: _serde::de::DeserializeOwned, { type Abi = ::Abi; #[inline] unsafe fn from_abi(js: Self::Abi) -> Self { let result = Self::from_js(&JsType::from_abi(js)); if let Err(err) = result { wasm_bindgen::throw_str(err.to_string().as_ref()); } result.unwrap_throw() } } impl OptionFromWasmAbi for GenericNewtype where Self: _serde::de::DeserializeOwned, { #[inline] fn is_none(js: &Self::Abi) -> bool { ::is_none(js) } } };