Skip to main content

wasm_js_bridge/
types.rs

1//! Shared descriptor types for code generation targets.
2
3/// A WASM-exported function descriptor.
4#[derive(Clone, Copy)]
5pub struct WasmFn {
6    /// camelCase JS function name (wasm-bindgen auto-converts snake_case).
7    pub name: &'static str,
8    /// Raw output of `file!()` at `#[wasm_export]` call site (e.g. `"src/foo_bar.rs"`).
9    /// Used by `bundle!` to group functions by source file → output stem.
10    pub file: &'static str,
11    /// Called at test runtime — returns TS parameter signature string.
12    pub ts_params: fn() -> String,
13    /// Called at test runtime — returns TS return type string.
14    pub ts_ret: fn() -> String,
15    /// Called at test runtime — returns Flow parameter signature string.
16    pub flow_params: fn() -> String,
17    /// Called at test runtime — returns Flow return type string.
18    pub flow_ret: fn() -> String,
19}
20
21/// An interface not modeled as a Rust struct (e.g. ad-hoc WASM return shapes).
22pub struct Interface {
23    /// Interface name.
24    pub name: &'static str,
25    /// Fields: `(name, type)`. All emitted as readonly/covariant.
26    pub fields: &'static [(&'static str, &'static str)],
27}
28
29/// A type alias (e.g. `export type AttrOp = PredicateOp`).
30pub struct TypeAlias {
31    /// Alias name.
32    pub name: &'static str,
33    /// Target type.
34    pub target: &'static str,
35}