Skip to main content

asupersync_browser_core/
exports.rs

1//! Concrete ABI export wrappers re-exported at the crate root.
2//!
3//! The dispatcher and host/browser bridge state live in [`crate::lib`]. This
4//! module owns the public v1 export surface so the implementation matches the
5//! documented boundary instead of leaving a stale placeholder module behind.
6
7#[cfg(target_arch = "wasm32")]
8use super::into_js_error;
9use super::{
10    abi_fingerprint_impl, abi_version_impl, fetch_request_impl, runtime_close_impl,
11    runtime_create_impl, scope_close_impl, scope_enter_impl, task_cancel_impl, task_join_impl,
12    task_spawn_impl, websocket_cancel_impl, websocket_close_impl, websocket_open_impl,
13    websocket_recv_impl, websocket_send_impl,
14};
15#[cfg(target_arch = "wasm32")]
16use wasm_bindgen::{JsValue, prelude::wasm_bindgen};
17
18/// `runtime_create` ABI symbol.
19#[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/// Host adapter for `runtime_create`.
26#[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/// `runtime_close` ABI symbol.
32#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = runtime_close))]
33#[cfg(target_arch = "wasm32")]
34pub fn runtime_close(
35    handle_json: String,
36    consumer_version_json: Option<String>,
37) -> Result<String, JsValue> {
38    runtime_close_impl(handle_json, consumer_version_json).map_err(into_js_error)
39}
40
41/// Host adapter for `runtime_close`.
42#[cfg(not(target_arch = "wasm32"))]
43pub fn runtime_close(
44    handle_json: String,
45    consumer_version_json: Option<String>,
46) -> Result<String, String> {
47    runtime_close_impl(handle_json, consumer_version_json)
48}
49
50/// `scope_enter` ABI symbol.
51#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = scope_enter))]
52#[cfg(target_arch = "wasm32")]
53pub fn scope_enter(
54    request_json: String,
55    consumer_version_json: Option<String>,
56) -> Result<String, JsValue> {
57    scope_enter_impl(request_json, consumer_version_json).map_err(into_js_error)
58}
59
60/// Host adapter for `scope_enter`.
61#[cfg(not(target_arch = "wasm32"))]
62pub fn scope_enter(
63    request_json: String,
64    consumer_version_json: Option<String>,
65) -> Result<String, String> {
66    scope_enter_impl(request_json, consumer_version_json)
67}
68
69/// `scope_close` ABI symbol.
70#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = scope_close))]
71#[cfg(target_arch = "wasm32")]
72pub fn scope_close(
73    handle_json: String,
74    consumer_version_json: Option<String>,
75) -> Result<String, JsValue> {
76    scope_close_impl(handle_json, consumer_version_json).map_err(into_js_error)
77}
78
79/// Host adapter for `scope_close`.
80#[cfg(not(target_arch = "wasm32"))]
81pub fn scope_close(
82    handle_json: String,
83    consumer_version_json: Option<String>,
84) -> Result<String, String> {
85    scope_close_impl(handle_json, consumer_version_json)
86}
87
88/// `task_spawn` ABI symbol.
89#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_spawn))]
90#[cfg(target_arch = "wasm32")]
91pub fn task_spawn(
92    request_json: String,
93    consumer_version_json: Option<String>,
94) -> Result<String, JsValue> {
95    task_spawn_impl(request_json, consumer_version_json).map_err(into_js_error)
96}
97
98/// Host adapter for `task_spawn`.
99#[cfg(not(target_arch = "wasm32"))]
100pub fn task_spawn(
101    request_json: String,
102    consumer_version_json: Option<String>,
103) -> Result<String, String> {
104    task_spawn_impl(request_json, consumer_version_json)
105}
106
107/// `task_join` ABI symbol.
108#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_join))]
109#[cfg(target_arch = "wasm32")]
110pub fn task_join(
111    handle_json: String,
112    outcome_json: String,
113    consumer_version_json: Option<String>,
114) -> Result<String, JsValue> {
115    task_join_impl(handle_json, outcome_json, consumer_version_json).map_err(into_js_error)
116}
117
118/// Host adapter for `task_join`.
119#[cfg(not(target_arch = "wasm32"))]
120pub fn task_join(
121    handle_json: String,
122    outcome_json: String,
123    consumer_version_json: Option<String>,
124) -> Result<String, String> {
125    task_join_impl(handle_json, outcome_json, consumer_version_json)
126}
127
128/// `task_cancel` ABI symbol.
129#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = task_cancel))]
130#[cfg(target_arch = "wasm32")]
131pub fn task_cancel(
132    request_json: String,
133    consumer_version_json: Option<String>,
134) -> Result<String, JsValue> {
135    task_cancel_impl(request_json, consumer_version_json).map_err(into_js_error)
136}
137
138/// Host adapter for `task_cancel`.
139#[cfg(not(target_arch = "wasm32"))]
140pub fn task_cancel(
141    request_json: String,
142    consumer_version_json: Option<String>,
143) -> Result<String, String> {
144    task_cancel_impl(request_json, consumer_version_json)
145}
146
147/// `fetch_request` ABI symbol.
148#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = fetch_request))]
149#[cfg(target_arch = "wasm32")]
150pub fn fetch_request(
151    request_json: String,
152    consumer_version_json: Option<String>,
153) -> Result<String, JsValue> {
154    fetch_request_impl(request_json, consumer_version_json).map_err(into_js_error)
155}
156
157/// Host adapter for `fetch_request`.
158#[cfg(not(target_arch = "wasm32"))]
159pub fn fetch_request(
160    request_json: String,
161    consumer_version_json: Option<String>,
162) -> Result<String, String> {
163    fetch_request_impl(request_json, consumer_version_json)
164}
165
166/// `websocket_open` bridge symbol.
167#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_open))]
168#[cfg(target_arch = "wasm32")]
169pub fn websocket_open(
170    request_json: String,
171    consumer_version_json: Option<String>,
172) -> Result<String, JsValue> {
173    websocket_open_impl(request_json, consumer_version_json).map_err(into_js_error)
174}
175
176/// Host adapter for `websocket_open`.
177#[cfg(not(target_arch = "wasm32"))]
178pub fn websocket_open(
179    request_json: String,
180    consumer_version_json: Option<String>,
181) -> Result<String, String> {
182    websocket_open_impl(request_json, consumer_version_json)
183}
184
185/// `websocket_send` bridge symbol.
186#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_send))]
187#[cfg(target_arch = "wasm32")]
188pub fn websocket_send(
189    request_json: String,
190    consumer_version_json: Option<String>,
191) -> Result<String, JsValue> {
192    websocket_send_impl(request_json, consumer_version_json).map_err(into_js_error)
193}
194
195/// Host adapter for `websocket_send`.
196#[cfg(not(target_arch = "wasm32"))]
197pub fn websocket_send(
198    request_json: String,
199    consumer_version_json: Option<String>,
200) -> Result<String, String> {
201    websocket_send_impl(request_json, consumer_version_json)
202}
203
204/// `websocket_recv` bridge symbol.
205#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_recv))]
206#[cfg(target_arch = "wasm32")]
207pub fn websocket_recv(
208    request_json: String,
209    consumer_version_json: Option<String>,
210) -> Result<String, JsValue> {
211    websocket_recv_impl(request_json, consumer_version_json).map_err(into_js_error)
212}
213
214/// Host adapter for `websocket_recv`.
215#[cfg(not(target_arch = "wasm32"))]
216pub fn websocket_recv(
217    request_json: String,
218    consumer_version_json: Option<String>,
219) -> Result<String, String> {
220    websocket_recv_impl(request_json, consumer_version_json)
221}
222
223/// `websocket_close` bridge symbol.
224#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_close))]
225#[cfg(target_arch = "wasm32")]
226pub fn websocket_close(
227    request_json: String,
228    consumer_version_json: Option<String>,
229) -> Result<String, JsValue> {
230    websocket_close_impl(request_json, consumer_version_json).map_err(into_js_error)
231}
232
233/// Host adapter for `websocket_close`.
234#[cfg(not(target_arch = "wasm32"))]
235pub fn websocket_close(
236    request_json: String,
237    consumer_version_json: Option<String>,
238) -> Result<String, String> {
239    websocket_close_impl(request_json, consumer_version_json)
240}
241
242/// `websocket_cancel` bridge symbol.
243#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = websocket_cancel))]
244#[cfg(target_arch = "wasm32")]
245pub fn websocket_cancel(
246    request_json: String,
247    consumer_version_json: Option<String>,
248) -> Result<String, JsValue> {
249    websocket_cancel_impl(request_json, consumer_version_json).map_err(into_js_error)
250}
251
252/// Host adapter for `websocket_cancel`.
253#[cfg(not(target_arch = "wasm32"))]
254pub fn websocket_cancel(
255    request_json: String,
256    consumer_version_json: Option<String>,
257) -> Result<String, String> {
258    websocket_cancel_impl(request_json, consumer_version_json)
259}
260
261/// `abi_version` ABI symbol.
262#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = abi_version))]
263#[cfg(target_arch = "wasm32")]
264pub fn abi_version() -> Result<String, JsValue> {
265    abi_version_impl().map_err(into_js_error)
266}
267
268/// Host adapter for `abi_version`.
269#[cfg(not(target_arch = "wasm32"))]
270pub fn abi_version() -> Result<String, String> {
271    abi_version_impl()
272}
273
274/// `abi_fingerprint` ABI symbol.
275#[cfg_attr(target_arch = "wasm32", wasm_bindgen(js_name = abi_fingerprint))]
276#[cfg(target_arch = "wasm32")]
277#[must_use]
278pub fn abi_fingerprint() -> u64 {
279    abi_fingerprint_impl()
280}
281
282/// Host adapter for `abi_fingerprint`.
283#[cfg(not(target_arch = "wasm32"))]
284#[must_use]
285pub const fn abi_fingerprint() -> u64 {
286    abi_fingerprint_impl()
287}