1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Per-target async runtime helpers.
//!
//! On native, this delegates to tokio's multi-threaded runtime. On
//! wasm32 the only available scheduler is the browser event loop, which
//! `wasm_bindgen_futures::spawn_local` drives. The two APIs differ on
//! `Send` bounds — tokio requires futures be `Send`; the wasm scheduler
//! is single-threaded so it does not — so each platform gets its own
//! signature.
//!
//! Use `crate::runtime::spawn` instead of `tokio::spawn` anywhere the
//! call site needs to compile on both targets.
use Future;
/// A marker that is `Send + Sync` on native and a no-op on wasm32.
///
/// Use as a supertrait — `pub trait Tool: MaybeSendSync { ... }` — so
/// concrete implementations whose internals (e.g., reqwest's browser
/// fetch client) aren't `Send` can still satisfy the bound on wasm.
/// Spawn a fire-and-forget future onto the platform's async runtime.
///
/// The future's output is discarded; there is no `JoinHandle` because
/// wasm_bindgen_futures doesn't return one. If you need to await the
/// result, await the future directly instead of spawning it.