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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! WebAssembly (WASM) support for the InferaDB SDK.
//!
//! This module provides WASM-specific utilities and compatibility helpers
//! for running the SDK in browser and other WASM environments.
//!
//! ## Feature Flag
//!
//! Enable WASM support by adding the `wasm` feature:
//!
//! ```toml
//! [dependencies]
//! inferadb = { version = "0.1", features = ["wasm"] }
//! ```
//!
//! ## Browser Usage
//!
//! When targeting `wasm32-unknown-unknown`, the SDK uses:
//! - `getrandom` with JS bindings for cryptographic randomness
//! - Browser's Fetch API via reqwest for HTTP requests
//! - `wasm-bindgen-futures` for async runtime integration
//!
//! ## Example
//!
//! ```rust,ignore
//! use inferadb::prelude::*;
//! use wasm_bindgen_futures::spawn_local;
//!
//! // In a WASM context (e.g., from a button click handler)
//! spawn_local(async move {
//! let client = Client::builder()
//! .url("https://api.inferadb.com")
//! .bearer_token("your-token")
//! .build()
//! .await
//! .expect("Failed to create client");
//!
//! let vault = client.organization("org_123").vault("vlt_456");
//! let allowed = vault.check("user:alice", "view", "doc:readme").await;
//! web_sys::console::log_1(&format!("Allowed: {:?}", allowed).into());
//! });
//! ```
//!
//! ## Limitations
//!
//! When running in WASM:
//! - The blocking API is not available (no threads in WASM)
//! - gRPC transport is not supported (use REST instead)
//! - Some timing operations may have reduced precision
//! - File system operations (like loading PEM keys) are not available
/// WASM platform detection.
///
/// Returns `true` if the SDK is running on a WASM target.
pub const
/// Browser platform detection.
///
/// Returns `true` if the SDK appears to be running in a browser context.
/// This checks for the `wasm32-unknown-unknown` target which is typically
/// used for browser WASM.
pub const
/// Node.js/Deno platform detection.
///
/// Returns `true` if the SDK appears to be running in a Node.js or Deno context.
pub const
/// Check if the current platform supports threads.
///
/// WASM typically doesn't have thread support (unless using wasm-threads),
/// so this returns `false` for WASM targets.
pub const
/// Check if the current platform supports file system operations.
///
/// Browsers don't have direct file system access, so this returns `false`
/// for browser WASM targets.
pub const