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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Target-aware marker bounds for native and browser storage implementations.
/// A portability bound that requires [`Send`] on native targets.
///
/// Native executors move storage sessions and their futures between tasks, so
/// those values must be `Send`. Browser IndexedDB implementations may instead
/// hold JavaScript values that cannot cross threads. Defining that difference
/// here keeps conditional bounds out of the storage traits and preserves their
/// native contract.
///
/// Native `async fn` trait implementations need no target-specific attribute;
/// use this marker on explicit future bounds that must retain the native
/// `Send` contract while permitting thread-local browser futures.
/// A portability bound that does not require [`Send`] in browsers.
///
/// IndexedDB handles can contain `JsValue`s, which are not `Send`. The browser
/// form therefore accepts every type while native builds retain the `Send`
/// supertrait. This applies only to `wasm32-unknown-unknown` browsers, not all
/// WebAssembly targets: `wasm32-wasip1-threads`, for example, has real threads.
/// Keeping the distinction in this marker leaves the native storage contract
/// intact.
///
/// Native `async fn` trait implementations need no target-specific attribute;
/// use this marker on explicit future bounds that may be `!Send` only in the
/// browser.
/// A portability bound that requires [`Sync`] on native targets.
///
/// Native executors may share storage sessions between tasks, so session and
/// error values at storage boundaries must be `Sync`. Browser IndexedDB
/// handles may contain JavaScript values that are not `Sync`; centralizing the
/// conditional requirement here keeps the native contract unchanged.
///
/// The browser exemption deliberately applies only to
/// `wasm32-unknown-unknown`. It does not use `target_family = "wasm"`, which
/// would incorrectly exempt threaded targets such as `wasm32-wasip1-threads`.
/// A portability bound that does not require [`Sync`] in browsers.
///
/// IndexedDB handles can contain `JsValue`s, which are not `Sync`, so browser
/// storage implementations need this marker to accept every type. Native and
/// threaded WebAssembly targets still receive the `Sync` supertrait; in
/// particular, the predicate excludes `wasm32-wasip1-threads`. Defining that
/// difference only here preserves the native storage contract.