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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
/// Conditional compilation module for WASM vs non-WASM targets.
///
/// This module provides traits that can be used to conditionally require `Send` and `Sync`
/// traits based on the target architecture. This avoids spreading conditional compilation
/// throughout the codebase and reduces duplication of otherwise very similar implementations.
///
/// # Purpose
///
/// In WASM targets (`target_arch = "wasm32"`), the `Send` and `Sync` traits are not
/// available or meaningful since WASM is single-threaded. However, in native targets,
/// these traits are often required for async operations and thread safety.
///
/// By using `NoWasmSend` and `NoWasmSync` instead of `Send` and `Sync` directly,
/// we can write code that works on both WASM and native targets without duplicating
/// implementations or spreading `#[cfg]` attributes throughout the codebase.
///
/// # Usage
///
/// Instead of:
/// ```text
/// async fn my_function<T: Send + Sync>(param: T) { ... }
/// ```
///
/// Use:
/// ```text
/// use crate::rpc::no_wasm::{NoWasmSend, NoWasmSync};
/// async fn my_function<T: NoWasmSend + NoWasmSync>(param: T) { ... }
/// ```
///
/// # Implementation Details
///
/// - On non-WASM targets: `NoWasmSend` requires `Send`, `NoWasmSync` requires `Sync`
/// - On WASM targets: Both traits have no requirements and are implemented for all types
pub
/// Conditional compilation module for WASM targets.
///
/// On WASM targets, `Send` and `Sync` traits are not available or meaningful
/// since WASM is single-threaded. These traits provide a unified interface
/// that works across all targets.
pub
pub use *;