Crate wasm_bindgen
Runtime support for the wasm-bindgen tool
This crate contains the runtime support necessary for wasm-bindgen the
attribute and tool. Crates pull in the #[wasm_bindgen] attribute through
this crate and this crate also provides JS bindings through the JsValue
interface.
Features
enable-interning
Enables the internal cache for wasm_bindgen::intern.
This feature currently enables the std feature, meaning that it is not
compatible with no_std environments.
std (default)
Enabling this feature will make the crate depend on the Rust standard library.
Disable this feature to use this crate in no_std environments.
strict-macro
All warnings the #[wasm_bindgen] macro emits are turned into hard errors.
This mainly affects unused attribute options.
Deprecated features
serde-serialize
Deprecated: Use the serde-wasm-bindgen crate instead.
Enables the JsValue::from_serde and JsValue::into_serde methods for
serializing and deserializing Rust types to and from JavaScript.
spans
Deprecated: This feature became a no-op in wasm-bindgen v0.2.20 (Sep 7, 2018).
Modules
Structs
-
Clamped
A wrapper type around slices and vectors for binding the
Uint8ClampedArrayarray in JS. -
JsError
Convenience type for use on exported
fn() -> Result<T, JsError>functions, where you wish to throw a JavaScriptErrorobject. - JsStatic Wrapper type for imported statics.
- JsThreadLocal Wrapper type for imported statics.
- JsValue Representation of an object owned by JS.
-
Parent
Storage wrapper for the auto-injected
parentfield on a struct that declares#[wasm_bindgen(extends = Parent)].
Traits
-
IntoJsGeneric
Value conversion from a type into its canonical
JsGenericform. - JsCast A trait for dynamic checked and unchecked casting between JS types.
-
JsGeneric
A convenience trait for types that erase to
JsValue. - JsStringLike Marker for types that cross the ABI as a JavaScript string.
-
UnwrapThrowExt
An extension trait for
Option<T>andResult<T, E>for unwrapping theTvalue, or throwing a JS error if it is not available.
Functions
-
exports
Returns a handle to this Wasm instance's
WebAssembly.Instance.prototype.exports -
externref_heap_live_count
Get the count of live
externrefs /JsValues inwasm-bindgen's heap. -
function_table
Returns a handle to this Wasm instance's
WebAssembly.Tablewhich is the indirect function table used by Rust -
instance
Returns a handle to this Wasm instance's
WebAssembly.Instance. This is only available when the final Wasm app is built with--target no-modules,--target web,--target denoor--target nodejs. It is unavailable for--target bundler. - 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. This is only available when the final Wasm app is built with--target no-modules,--target web,--target denoor--target nodejs. It is unavailable for--target bundler. - throw_str Throws a JS exception.
- throw_val Rethrow a JS exception
- unintern Removes a Rust string from the intern cache.