Registry / async / wasm-bindgen-futures

wasm-bindgen-futures

JSON →
library0.4.75rscratesunverified

Bridging the gap between Rust Futures and JavaScript Promises.

# Cargo.toml [dependencies] wasm-bindgen-futures = "0.4.75"
INSTALL
IMPORT
SIG · WASM-BINDGEN-FUTUR
W
wasm-bindgen-futures
asyncrustv0.4.75
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JsFuture
use wasm_bindgen_futures::JsFuture;

Converts a JavaScript Promise into a Rust Future.

use wasm_bindgen::prelude::*; use wasm_bindgen_futures::JsFuture; #[wasm_bindgen] pub async fn fetch_url(url: String) -> Result<JsValue, JsValue> { let resp = JsFuture::from(web_sys::window().unwrap().fetch_with_str(&url)).await?; Ok(resp) }
Debug
Known issues
gotchaOnly works in WebAssembly targets; requires `wasm-bindgen` and a browser or Node.js environment.
fix
Ensure target is `wasm32-unknown-unknown` and add `wasm-bindgen` dependency.
affects: >=0.4.0
Upgrade
Version history
0.4.75latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
36
Resources
wasm-bindgen-futures — cargo add wasm-bindgen-futures · libregistry