impl_main_wasm_traits

Macro impl_main_wasm_traits 

Source
macro_rules! impl_main_wasm_traits {
    ($type_name:ident $(< $($generics:ident),+ >)?) => { ... };
}
Expand description

A macro that implements main wasm traits for the given type. These traits are the necessary ones to be able to send/receive the given type through wasm bindgen boundry. The type needs to have serde::Serialize, serde::Deserialize and tsify::Tsify traits implemented.

Example:

#[derive(Serialize, Deserialize, Tsify)]
#[serde(rename_all = "camelCase")]
pub struct A {
    pub field: String,
    pub other_field: u8,
}
impl_main_wasm_traits!(A);

#[wasm_bindgen]
pub fn some_fn(arg: A) -> String {
    // body
}

#[wasm_bindgen]
pub fn some_other_fn(arg: String) -> Option<A> {
    // body
}