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
//! eq-swift — Zero-config Rust-to-Swift FFI
//!
//! A thin, ergonomic wrapper around [UniFFI](https://github.com/mozilla/uniffi-rs)
//! that lets you write your entire foreign interface in Rust — no UDL files, no
//! `build.rs`, no `setup!()` call, no duplication.
//!
//! Just annotate your items with `#[eqswift::export]` or `#[derive(eqswift::Record)]`
//! and build. The first `#[eqswift::export]` automatically initializes UniFFI.
//!
//! # Quick Start
//!
//! ```ignore
//! #[eqswift::export]
//! pub fn add(a: u32, b: u32) -> u32 {
//! a + b
//! }
//!
//! #[derive(eqswift::Record)]
//! pub struct Person {
//! pub name: String,
//! pub age: u32,
//! }
//!
//! #[derive(eqswift::Object)]
//! pub struct Greeter;
//!
//! #[eqswift::export]
//! impl Greeter {
//! // Automatically detected as constructor — no attribute needed
//! pub fn new() -> Self {
//! Self
//! }
//!
//! pub fn greet(&self, name: String) -> String {
//! format!("Hello, {name}!")
//! }
//! }
//! ```
//!
//! Then build and generate Swift bindings:
//! ```bash
//! cargo build
//! cargo eqswift swift --out-dir eq-swift/swift/Generated
//! ```
//!
//! # Macros
//!
//! | Macro | Purpose |
//! |-------|---------|
//! | [`export`](eqswift_macros::export) | Mark a free function or `impl` block for export. Auto-initializes UniFFI on first use. |
//! | [`Record`](uniffi::Record) | Derive for plain data structs (Swift `struct`). |
//! | [`Object`](uniffi::Object) | Derive for reference types with methods (Swift `class`). |
//! | [`Enum`](uniffi::Enum) | Derive for enums. |
//! | [`Error`](uniffi::Error) | Derive for error enums. |
//! | [`setup!`](eqswift_macros::setup) | Explicit initialization (optional, see [`export`](eqswift_macros::export)). |
//!
//! # Supported Types
//!
//! Most Rust primitives map directly to Swift:
//!
//! | Rust | Swift |
//! |------|-------|
//! | `u32` | `UInt32` |
//! | `i32` | `Int32` |
//! | `f64` | `Double` |
//! | `bool` | `Bool` |
//! | `String` | `String` |
//! | `Vec<T>` | `[T]` |
//! | `Option<T>` | `T?` |
//! | `Result<T, E>` | `throws` |
//!
//! See the [UniFFI type docs](https://mozilla.github.io/uniffi-rs/latest/types/builtin_types.html)
//! for the complete list.
pub use ;
// Re-export UniFFI derives so users can write `#[derive(eqswift::Record)]` etc.
pub use Record;
pub use Object;
pub use Enum;
pub use Error;
// Allow using `eqswift::` paths inside this crate too.
extern crate self as eqswift;
// ---------------------------------------------------------------------------
// Example API (smoke test — these items are exported to Swift)
// ---------------------------------------------------------------------------
/// A simple data record exported to Swift as a `struct`.
/// An object exported to Swift as a `class` with methods.
;
/// Add two numbers.
/// Return the crate version string.