Expand description
Unified wasm-bindgen shim crate
This crate transparently re-exports either:
- wry-bindgen-core for desktop targets (non-wasm32)
- wasm-bindgen for wasm32 targets
The #[wasm_bindgen] macro is a shim that expands to both implementations
wrapped in cfg-conditional modules.
Modules§
- __rt
- Runtime module for wasm-bindgen compatibility. This module provides the wbg_cast function used for type casting.
- alloc
- The Rust core allocation and collections library
- batch
- Batching system for grouping multiple JS operations into single messages.
- closure
- Re-export of the Closure type for wasm-bindgen API compatibility.
Allows
use wasm_bindgen::closure::Closure; - convert
- Conversion traits for wasm-bindgen API compatibility.
- encode
- Core encoding and decoding traits for the binary protocol.
- function
- JavaScript function references and Rust callback management.
- inventory
- github crates-io docs-rs
- prelude
- Prelude module for common imports
- runtime
- Runtime setup and event loop management.
- wry
- Reusable wry-bindgen state for integrating with existing wry applications.
Macros§
- link_to
- The link_to proc-macro for JavaScript module linking.
Structs§
- Clamped
- A wrapper type around slices and vectors for binding the
Uint8ClampedArrayin JS. - Closure
- Closure type for passing Rust closures to JavaScript.
- Decoded
Data - Decoded binary data with aligned buffer access.
- Encoded
Data - Encoder for building binary messages.
- Inline
JsModule - Inline JS module info
- JSFunction
- A reference to a JavaScript function that can be called from Rust.
- JsClass
Member Spec - Specification for a member of an exported Rust class
- JsError
- A JavaScript Error object.
- JsExport
Spec - Specification for an exported Rust function/method callable from JavaScript.
- JsFunction
Spec - Function specification for the registry
- JsThread
Local - A thread-local accessor for lazily initialized JavaScript values.
- JsValue
- An opaque reference to a JavaScript heap object.
- Lazy
JsFunction - A type that dynamically resolves to a JSFunction from the registry on first use.
Enums§
- Decode
Error - Error type for decoding binary IPC messages.
- JsClass
Member Kind - Type of class member for exported Rust structs
Traits§
- Batchable
Result - Trait for return types that can be used in batched JS calls. Determines how the type behaves during batching.
- Binary
Decode - Trait for decoding values from the binary protocol. Each type specifies how to deserialize itself.
- Binary
Encode - Trait for encoding Rust values into the binary protocol. Each type specifies how to serialize itself.
- Encode
Type Def - Trait for types that can encode their type definition into the binary protocol. This is used to send type information to JavaScript for callback arguments.
- JsCast
- Trait for types that can be cast to and from JsValue.
- Unwrap
Throw Ext - Extension trait for Option to unwrap or throw a JS error. This is API-compatible with wasm-bindgen’s UnwrapThrowExt.
- Wasm
Closure - Trait for closure types that can be wrapped and passed to JavaScript.
This trait is implemented for all
dyn FnMut(...)variants.
Functions§
- batch
- Execute operations inside a batch. Operations that return opaque types (like JsValue) will be batched and executed together. Operations that return non-opaque types will flush the batch to get the actual result.
- exports
- Returns a handle to this Wasm instance’s
WebAssembly.Instance.prototype.exports. - externref_
heap_ live_ count - Returns the number of live externref objects.
- extract_
rust_ handle - function_
table - Returns a handle to this Wasm instance’s
WebAssembly.Table(indirect function table). - intern
- Interns Rust strings so that it’s much faster to send them to JS.
- memory
- Returns a handle to this Wasm instance’s
WebAssembly.Memory. - module
- Returns a handle to this Wasm instance’s
WebAssembly.Module. - throw_
str - Throw a JS exception with the given message.
- throw_
val - unintern
- Removes a Rust string from the intern cache.
Attribute Macros§
- __
wasm_ bindgen_ class_ marker - Internal class marker macro for impl method expansion.
- wasm_
bindgen - The main wasm_bindgen attribute macro.