aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-02-05 15:53:34 +0100
committerGitHub <noreply@github.com>2023-02-05 15:53:34 +0100
commit802d7dfee77a3f58ee14a7ef6e2454e5aae62cbb (patch)
tree1c63107fafa7b535acd1a31a2e317e7535f85b62 /docs
parent24cabc6019e702ac888a33311532a9832863b572 (diff)
downloadFlightCore-802d7dfee77a3f58ee14a7ef6e2454e5aae62cbb.tar.gz
FlightCore-802d7dfee77a3f58ee14a7ef6e2454e5aae62cbb.zip
feat: Auto-generate TS bindings (#140)
* feat: Initial trial to auto-generate TS bindings That way instead of manually duplicating code, we can just run `cargo test` to generate them. * fix: Update forgotten imports * refactor: Move FlightCoreVersion to autogen bind TypeScript binding autogenerated from Rust code * refactor: Move ReleaseInfo to autogen binding TypeScript binding autogenerated from Rust code * docs: Explain how to generate TS binds from Rust * feat: Check for binding changes in CI Checks for uncommitted binding changes in CI and fails if they differ * style: Formatting fixes
Diffstat (limited to 'docs')
-rw-r--r--docs/DEVELOPMENT.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md
index 58714a09..8dbb1cea 100644
--- a/docs/DEVELOPMENT.md
+++ b/docs/DEVELOPMENT.md
@@ -158,6 +158,26 @@ else {
```
+### Auto-generating TypeScript bindings for Rust types
+
+This codebases uses [`ts-rs`](https://crates.io/crates/ts-rs) to generate TypeScript interfaces from Rust code.
+
+To generate new bindings, [use the appropriate macros](https://docs.rs/ts-rs/6.2.1/ts_rs/#get-started)
+
+```Rust
+use ts_rs::TS;
+
+#[derive(TS)]
+#[ts(export)]
+struct User {
+ user_id: i32,
+ first_name: String,
+ last_name: String,
+}
+```
+
+then simply run `cargo test`. The generated bindings are placed in `src-tauri/bindings/`. Make sure to add and commit them as well!
+
## Other
This repo uses [EditorConfig](https://editorconfig.org/) to define some basic formatting rules. Find a plugin for your IDE [here](https://editorconfig.org/#download).