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:
BinaryEncode/BinaryDecode- Core encoding/decoding traits for Rust typesJSFunction- JSFunction type for calling JavaScript functionsbatch- Batching helpers for grouping multiple JS operationswry- Event loop and Wry integration
Re-exports§
pub use closure::Closure;pub use closure::ScopedClosure;pub use convert::IntoJsGeneric;pub use convert::JsGeneric;pub use sys::JsOption;pub use sys::Null;pub use sys::Promising;pub use sys::Undefined;
Modules§
- batch
- Batching system for grouping multiple JS operations into single messages.
- closure
- Closure compatibility types and traits.
- convert
- Conversion traits for wasm-bindgen API compatibility.
- prelude
- Prelude module for common imports
- sys
- JavaScript system value wrappers and promise compatibility traits.
- 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. - Decoded
Data - Decoded binary data with aligned buffer access.
- Encoded
Data - Encoder for building binary messages.
- JSFunction
- A reference to a JavaScript function that can be called from Rust.
- JsError
- A JavaScript Error object.
- JsStatic
Deprecated - Legacy wrapper for imported statics.
- JsThread
Local - A thread-local accessor for lazily initialized JavaScript values.
- JsValue
- An opaque reference to a JavaScript heap object.
- Parent
- Storage wrapper for the auto-injected parent field on extended Rust types.
- Ref
- RefMut
Enums§
- Decode
Error - Error type for decoding binary IPC messages.
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.
- Erasable
Generic - Marker for types whose generic parameters erase to one stable runtime representation.
- 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.
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.
- function_
table - Returns a handle to this Wasm instance’s
WebAssembly.Table(indirect function table). - instance
- Returns a handle to this Wasm instance’s
WebAssembly.Instance. - 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.