Crate wasm_bindgen

Source
Expand description

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.

§msrv (default)

Enables Rust language features that require a higher MSRV. Enabling this feature on older compilers will NOT result in a compilation error, the newer language features will simply not be used.

When compiling with Rust v1.78 or later, this feature enables better error messages for invalid methods on structs and enums.

§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).

Re-exports§

  • pub use crate::cast::JsObject;

Modules§

  • Support for long-lived closures in wasm-bindgen
  • ⚠️ Unstable
  • A module which is typically glob imported.

Macros§

  • This macro takes a JS module as input and returns a URL that can be used to access it at runtime.

Structs§

  • A wrapper type around slices and vectors for binding the Uint8ClampedArray array in JS.
  • Convenience type for use on exported fn() -> Result<T, JsError> functions, where you wish to throw a JavaScript Error object.
  • JsStaticDeprecated
    Wrapper type for imported statics.
  • Wrapper type for imported statics.
  • Representation of an object owned by JS.

Traits§

  • A trait for checked and unchecked casting between JS types.
  • An extension trait for Option<T> and Result<T, E> for unwrapping the T value, or throwing a JS error if it is not available.

Functions§

  • Returns a handle to this Wasm instance’s WebAssembly.Instance.prototype.exports
  • Get the count of live externrefs / JsValues in wasm-bindgen’s heap.
  • Returns a handle to this Wasm instance’s WebAssembly.Table which is the indirect function table used by Rust
  • Interns Rust strings so that it’s much faster to send them to JS.
  • Returns a handle to this Wasm instance’s WebAssembly.Memory
  • 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 or --target web.
  • Throws a JS exception.
  • Rethrow a JS exception
  • Removes a Rust string from the intern cache.