Expand description
wry-bindgen - Runtime support for wasm-bindgen-style bindings over Wry’s WebView
This crate provides the runtime types and traits needed for the #[wasm_bindgen]
attribute macro to generate code that works with Wry’s IPC protocol.
§Architecture
The crate is organized into several modules:
Re-exports§
pub extern crate alloc;pub use batch::batch;pub use encode::BatchableResult;pub use encode::BinaryDecode;pub use encode::BinaryEncode;pub use encode::EncodeTypeDef;pub use function::JSFunction;pub use inventory;
Modules§
- __rt
- Runtime module for wasm-bindgen compatibility. This module provides the wbg_cast function used for type casting.
- 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.
- 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
- Link to a JS file for use with workers/worklets.
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
- 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§
- 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§
- 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 - The main wasm_bindgen attribute macro.