1#[cfg(target_arch = "wasm32")]
8use super::into_js_error;
9use super::{
10 abi_fingerprint_impl, abi_version_impl, browser_operator_snapshot_impl, fetch_request_impl,
11 runtime_close_impl, runtime_create_impl, scope_close_impl, scope_enter_impl, task_cancel_impl,
12 task_join_impl, task_spawn_impl, websocket_cancel_impl, websocket_close_impl,
13 websocket_open_impl, websocket_recv_impl, websocket_send_impl,
14};
15#[cfg(target_arch = "wasm32")]
16use wasm_bindgen::{JsValue, prelude::wasm_bindgen};
17
18#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = runtime_create))]
20#[cfg(target_arch = "wasm32")]
21pub fn runtime_create(consumer_version_json: Option<String>) -> Result<String, JsValue> {
22 runtime_create_impl(consumer_version_json).map_err(into_js_error)
23}
24
25#[cfg(not(target_arch = "wasm32"))]
27pub fn runtime_create(consumer_version_json: Option<String>) -> Result<String, String> {
28 runtime_create_impl(consumer_version_json)
29}
30
31#[cfg_attr(
33 target_arch = "wasm32",
34 wasm_bindgen(js_name = browser_operator_snapshot)
35)]
36#[cfg(target_arch = "wasm32")]
37pub fn browser_operator_snapshot() -> Result<String, JsValue> {
38 browser_operator_snapshot_impl().map_err(into_js_error)
39}
40
41#[cfg(not(target_arch = "wasm32"))]
43pub fn browser_operator_snapshot() -> Result<String, String> {
44 browser_operator_snapshot_impl()
45}
46
47#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = runtime_close))]
49#[cfg(target_arch = "wasm32")]
50pub fn runtime_close(
51 handle_json: String,
52 consumer_version_json: Option<String>,
53) -> Result<String, JsValue> {
54 runtime_close_impl(handle_json, consumer_version_json).map_err(into_js_error)
55}
56
57#[cfg(not(target_arch = "wasm32"))]
59pub fn runtime_close(
60 handle_json: String,
61 consumer_version_json: Option<String>,
62) -> Result<String, String> {
63 runtime_close_impl(handle_json, consumer_version_json)
64}
65
66#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = scope_enter))]
68#[cfg(target_arch = "wasm32")]
69pub fn scope_enter(
70 request_json: String,
71 consumer_version_json: Option<String>,
72) -> Result<String, JsValue> {
73 scope_enter_impl(request_json, consumer_version_json).map_err(into_js_error)
74}
75
76#[cfg(not(target_arch = "wasm32"))]
78pub fn scope_enter(
79 request_json: String,
80 consumer_version_json: Option<String>,
81) -> Result<String, String> {
82 scope_enter_impl(request_json, consumer_version_json)
83}
84
85#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = scope_close))]
87#[cfg(target_arch = "wasm32")]
88pub fn scope_close(
89 handle_json: String,
90 consumer_version_json: Option<String>,
91) -> Result<String, JsValue> {
92 scope_close_impl(handle_json, consumer_version_json).map_err(into_js_error)
93}
94
95#[cfg(not(target_arch = "wasm32"))]
97pub fn scope_close(
98 handle_json: String,
99 consumer_version_json: Option<String>,
100) -> Result<String, String> {
101 scope_close_impl(handle_json, consumer_version_json)
102}
103
104#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_spawn))]
106#[cfg(target_arch = "wasm32")]
107pub fn task_spawn(
108 request_json: String,
109 consumer_version_json: Option<String>,
110) -> Result<String, JsValue> {
111 task_spawn_impl(request_json, consumer_version_json).map_err(into_js_error)
112}
113
114#[cfg(not(target_arch = "wasm32"))]
116pub fn task_spawn(
117 request_json: String,
118 consumer_version_json: Option<String>,
119) -> Result<String, String> {
120 task_spawn_impl(request_json, consumer_version_json)
121}
122
123#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_join))]
125#[cfg(target_arch = "wasm32")]
126pub fn task_join(
127 handle_json: String,
128 outcome_json: String,
129 consumer_version_json: Option<String>,
130) -> Result<String, JsValue> {
131 task_join_impl(handle_json, outcome_json, consumer_version_json).map_err(into_js_error)
132}
133
134#[cfg(not(target_arch = "wasm32"))]
136pub fn task_join(
137 handle_json: String,
138 outcome_json: String,
139 consumer_version_json: Option<String>,
140) -> Result<String, String> {
141 task_join_impl(handle_json, outcome_json, consumer_version_json)
142}
143
144#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_cancel))]
146#[cfg(target_arch = "wasm32")]
147pub fn task_cancel(
148 request_json: String,
149 consumer_version_json: Option<String>,
150) -> Result<String, JsValue> {
151 task_cancel_impl(request_json, consumer_version_json).map_err(into_js_error)
152}
153
154#[cfg(not(target_arch = "wasm32"))]
156pub fn task_cancel(
157 request_json: String,
158 consumer_version_json: Option<String>,
159) -> Result<String, String> {
160 task_cancel_impl(request_json, consumer_version_json)
161}
162
163#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = fetch_request))]
165#[cfg(target_arch = "wasm32")]
166pub fn fetch_request(
167 request_json: String,
168 consumer_version_json: Option<String>,
169) -> Result<String, JsValue> {
170 fetch_request_impl(request_json, consumer_version_json).map_err(into_js_error)
171}
172
173#[cfg(not(target_arch = "wasm32"))]
175pub fn fetch_request(
176 request_json: String,
177 consumer_version_json: Option<String>,
178) -> Result<String, String> {
179 fetch_request_impl(request_json, consumer_version_json)
180}
181
182#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_open))]
184#[cfg(target_arch = "wasm32")]
185pub fn websocket_open(
186 request_json: String,
187 consumer_version_json: Option<String>,
188) -> Result<String, JsValue> {
189 websocket_open_impl(request_json, consumer_version_json).map_err(into_js_error)
190}
191
192#[cfg(not(target_arch = "wasm32"))]
194pub fn websocket_open(
195 request_json: String,
196 consumer_version_json: Option<String>,
197) -> Result<String, String> {
198 websocket_open_impl(request_json, consumer_version_json)
199}
200
201#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_send))]
203#[cfg(target_arch = "wasm32")]
204pub fn websocket_send(
205 request_json: String,
206 consumer_version_json: Option<String>,
207) -> Result<String, JsValue> {
208 websocket_send_impl(request_json, consumer_version_json).map_err(into_js_error)
209}
210
211#[cfg(not(target_arch = "wasm32"))]
213pub fn websocket_send(
214 request_json: String,
215 consumer_version_json: Option<String>,
216) -> Result<String, String> {
217 websocket_send_impl(request_json, consumer_version_json)
218}
219
220#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_recv))]
222#[cfg(target_arch = "wasm32")]
223pub fn websocket_recv(
224 request_json: String,
225 consumer_version_json: Option<String>,
226) -> Result<String, JsValue> {
227 websocket_recv_impl(request_json, consumer_version_json).map_err(into_js_error)
228}
229
230#[cfg(not(target_arch = "wasm32"))]
232pub fn websocket_recv(
233 request_json: String,
234 consumer_version_json: Option<String>,
235) -> Result<String, String> {
236 websocket_recv_impl(request_json, consumer_version_json)
237}
238
239#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_close))]
241#[cfg(target_arch = "wasm32")]
242pub fn websocket_close(
243 request_json: String,
244 consumer_version_json: Option<String>,
245) -> Result<String, JsValue> {
246 websocket_close_impl(request_json, consumer_version_json).map_err(into_js_error)
247}
248
249#[cfg(not(target_arch = "wasm32"))]
251pub fn websocket_close(
252 request_json: String,
253 consumer_version_json: Option<String>,
254) -> Result<String, String> {
255 websocket_close_impl(request_json, consumer_version_json)
256}
257
258#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_cancel))]
260#[cfg(target_arch = "wasm32")]
261pub fn websocket_cancel(
262 request_json: String,
263 consumer_version_json: Option<String>,
264) -> Result<String, JsValue> {
265 websocket_cancel_impl(request_json, consumer_version_json).map_err(into_js_error)
266}
267
268#[cfg(not(target_arch = "wasm32"))]
270pub fn websocket_cancel(
271 request_json: String,
272 consumer_version_json: Option<String>,
273) -> Result<String, String> {
274 websocket_cancel_impl(request_json, consumer_version_json)
275}
276
277#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = abi_version))]
279#[cfg(target_arch = "wasm32")]
280pub fn abi_version() -> Result<String, JsValue> {
281 abi_version_impl().map_err(into_js_error)
282}
283
284#[cfg(not(target_arch = "wasm32"))]
286pub fn abi_version() -> Result<String, String> {
287 abi_version_impl()
288}
289
290#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = abi_fingerprint))]
292#[cfg(target_arch = "wasm32")]
293#[must_use]
294pub fn abi_fingerprint() -> u64 {
295 abi_fingerprint_impl()
296}
297
298#[cfg(not(target_arch = "wasm32"))]
300#[must_use]
301pub const fn abi_fingerprint() -> u64 {
302 abi_fingerprint_impl()
303}