bomboni_wasm
WebAssembly utilities for the Bomboni library. This crate provides utilities for working with WebAssembly in Rust, including JavaScript interoperability, console logging, and TypeScript declaration generation for Rust types.Main Exports
Wasm Trait
Trait for converting between Rust types and JavaScript values.Methods
to_js
Converts this value to a JavaScript value.
- Returns:
Result<Self::JsType, serde_wasm_bindgen::Error> - Errors: Will return error if serialization fails
from_js
Converts a JavaScript value to this Rust type.
- Parameters:
js: JavaScript value (any type that implementsInto<JsValue>)
- Returns:
Result<Self, serde_wasm_bindgen::Error> - Errors: Will return error if deserialization fails
Example
Console Logging
Themacros module provides console logging utilities for WebAssembly.
Functions
log
Logs a message to the browser console.
error
Logs an error message to the browser console.
Macros
console_log!
Logs a formatted message to the browser console.
console_error!
Logs a formatted error message to the browser console.
Example
Re-exports
When thederive feature is enabled, this crate re-exports the derive macro:
#[derive(Wasm)] directly.
TypeScript Declaration Generation
Types annotated with#[derive(Wasm)] automatically generate TypeScript declarations that can be exported alongside your WASM bindings.
Related
- bomboni_wasm_core - Core types for TypeScript generation
- bomboni_wasm_derive - Derive macro implementation