Crate wasm_bindgen_helper

Crate wasm_bindgen_helper 

Source
Expand description

Provides utilities, helpers and macros to easily build and customize wasm_bindgen bindings.

Modules§

macros
prelude

Macros§

add_ts_content
Adds/appends the given string literal to wasm bindgen typescript bindings. This is just a sugar for wasm_bindgen typescript_custom_section, so the given text can be anything, from typescript comment to type declarations or any other valid .d.ts content.
impl_complementary_wasm_traits
Implements complementary wasm traits for the given type. Needs impl_main_wasm_traits to be implemented first. It allows a type to be used on async functions normally or as ref or as Vec<> etc. The type needs to have serde::Serialize, serde::Deserialize and tsify::Tsify traits implemented.
impl_custom_tsify
Implements tsify::Tsify with the given type declaration for the given rust type (structs and enums) identifier.
impl_main_wasm_traits
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.
impl_wasm_traits
Implement all wasm traits for the given type. that is impl_main_wasm_traits and impl_complementary_wasm_traits. The type needs to have serde::Serialize, serde::Deserialize and tsify::Tsify traits implemented.

Functions§

bytes_serilializer
Serializer fn for serializing Vec<u8> as bytes (Uint8Array for js) Example:
serialize_btreemap_as_object
Serializer fn that serializes BTreeMap as k/v object. in js it would be plain js object and not js Map.
serialize_hashmap_as_object
Serializer fn that serializes HashMap as k/v object. in js it would be plain js object and not js Map.