Crate tokio_with_wasm

source ·
Expand description

A library that adapts the popular async runtime tokio for web browsers.

It provides a similar set of features specifically for web applications by leveraging the JavaScript web API.

This library includes JavaScript glue code to mimic the behavior of real tokio, making it possible to run asynchronous Rust code in the browser. Since tokio_with_wasm adapts to the JavaScript event loop and does not include its own runtime, some advanced features of tokio might not be fully supported.

Re-exports§

Modules§

  • Synchronization primitives for use in asynchronous contexts.
  • Asynchronous green-threads.
  • Utilities for tracking time.

Macros§

  • Waits on multiple concurrent branches, returning when all branches complete.
  • Pins a value on the stack.
  • Waits on multiple concurrent branches, returning when the first branch completes, cancelling the remaining branches.
  • Waits on multiple concurrent branches, returning when all branches complete with Ok(_) or on the first Err(_).

Functions§

Attribute Macros§

  • Attribute macro that mimics tokio::main. This macro returns a function that simply spawns the given future inside the JavaScript environment. To execute the function, you might need to use #[wasm_bindgen(start)] in addition to this macro.