bomboni_wasm_derive
Derive macro for generating WASM bindings and TypeScript declarations from Rust types.Derive Macro
Wasm
Derive macro for generating WASM bindings.- TypeScript declarations for your Rust types
- Automatic serialization/deserialization using
serde-wasm-bindgen - WASM ABI implementations for JavaScript interop
- The
Wasmtrait implementation
Basic Usage
Attributes
The#[wasm] attribute can be used to customize the generated bindings.
Container Attributes
These attributes are applied to structs and enums.wasm_bindgen_crate
Custom path to the wasm-bindgen crate.
js_sys_crate
Custom path to the js-sys crate.
bomboni_crate
Custom path to the bomboni crate.
bomboni_wasm_crate
Custom path to the bomboni_wasm crate.
wasm_abi
Generate both IntoWasmAbi and FromWasmAbi implementations.
into_wasm_abi
Generate IntoWasmAbi implementation.
from_wasm_abi
Generate FromWasmAbi implementation.
enum_value
Generate enum value object for string enums.
js_value
Custom JsValue conversion configuration.
proxy
Use a proxy type for WASM bindings.
rename
Custom name for the type in TypeScript.
rename_all
Rename rule for all fields and variants.
lowercaseUPPERCASEPascalCasecamelCasesnake_caseSCREAMING_SNAKE_CASEkebab-caseSCREAMING-KEBAB-CASE
rename_wrapper
Control wrapper type renaming for protobuf wrappers.
override_type
Override the generated TypeScript type.
change_ref / change_refs
Change reference type names.
Field Attributes
These attributes are applied to struct fields.rename
Custom name for the field in TypeScript.
override_type
Override the TypeScript type for this field.
always_some
Force the field to always be present in TypeScript (removes Option).
rename_wrapper
Control wrapper type renaming for this field.
change_ref / change_refs
Change reference type names for this field.
Variant Attributes
These attributes are applied to enum variants.rename
Custom name for the variant in TypeScript.
override_type
Override the TypeScript type for this variant.
Enum Tagging
The macro respects serde’s enum tagging attributes:External Tagging (default)
Internal Tagging
Adjacent Tagging
Complete Example
Related
- bomboni_wasm - Main WASM utilities
- bomboni_wasm_core - Core types