Crate wasm_bindgen_futures

wasm_bindgen_futures0.4.50

  • All Items

Crate Items

  • Re-exports
  • Modules
  • Structs
  • Functions
  • Attribute Macros

Crates

  • js_sys
  • wasm_bindgen
  • wasm_bindgen_futures
  • web_sys

Crate wasm_bindgen_futures

Source
Expand description

Converting between JavaScript Promises to Rust Futures.

This crate provides a bridge for working with JavaScript Promise types as a Rust Future, and similarly contains utilities to turn a rust Future into a JavaScript Promise. This can be useful when working with asynchronous or otherwise blocking work in Rust (wasm), and provides the ability to interoperate with JavaScript events and JavaScript I/O primitives.

There are three main interfaces in this crate currently:

  1. JsFuture

    A type that is constructed with a Promise and can then be used as a Future<Output = Result<JsValue, JsValue>>. This Rust future will resolve or reject with the value coming out of the Promise.

  2. future_to_promise

    Converts a Rust Future<Output = Result<JsValue, JsValue>> into a JavaScript Promise. The future’s result will translate to either a resolved or rejected Promise in JavaScript.

  3. spawn_local

    Spawns a Future<Output = ()> on the current thread. This is the best way to run a Future in Rust without sending it to JavaScript.

These three items should provide enough of a bridge to interoperate the two systems and make sure that Rust/JavaScript can work together with asynchronous and I/O work.

Re-exports§

  • pub use js_sys;
  • pub use wasm_bindgen;

Modules§

  • streamfutures-core-03-stream
    Converting JavaScript AsyncIterators to Rust Streams.

Structs§

  • JsFuture
    A Rust Future backed by a JavaScript Promise.

Functions§

  • future_to_promise
    Converts a Rust Future into a JavaScript Promise.
  • spawn_local
    Runs a Rust Future on the current thread.

Attribute Macros§

  • wasm_bindgen
    A list of all the attributes can be found here: https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/index.html

Results

in 
Settings
Help
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.