Skip to content

Commit b729ab9

Browse files
committed
chore: update README and Cargo metadata
1 parent 5842467 commit b729ab9

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
edition = "2021"
33
name = "tauri-ipc-macros"
44
version = "0.1.2"
5+
description = "IPC bindings for using Tauri with a Rust Frontend (e.g. leptos)"
6+
license = "BSD-3-Clause"
7+
homepage = "https://github.com/jvatic/tauri-ipc-macros"
8+
repository = "https://github.com/jvatic/tauri-ipc-macros"
9+
authors = ["Jesse Stuart <[email protected]>"]
510

611
[lib]
712
proc-macro = true

README.md

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# tauri-ipc-macros
22

3-
![rust workflow](https://github.com/jvatic/tauri-bindgen-rs-macros/actions/workflows/rust.yml/badge.svg)
3+
![rust workflow](https://github.com/jvatic/tauri-ipc-macros/actions/workflows/rust.yml/badge.svg)
44

5-
This is an *experimental* crate to aid in generating Rust IPC bindings for [Tauri](https://tauri.app/) commands (for those of us who'd like to use Rust for the front-end). Please review the code before using it.
5+
IPC bindings for using [Tauri](https://v2.tauri.app/) with a Rust Frontend (e.g.
6+
[leptos](https://v2.tauri.app/start/frontend/leptos/)).
7+
8+
**NOTE:** The API is currently unstable and may change.
69

710
## Why
811

9-
I couldn't find a comfortable way of defining commands that would maintain type safety with Tauri IPC bindings for a Rust frontend. So this is a crude attempt at solving this without changing too much about how the commands are defined.
12+
I couldn't find a comfortable way of defining commands that would maintain type
13+
safety with Tauri IPC bindings for a Rust Frontend. So this is a crude attempt
14+
at solving this without changing too much about how the commands are defined.
1015

1116
## Usage
1217

@@ -41,9 +46,12 @@ I couldn't find a comfortable way of defining commands that would maintain type
4146
}
4247
```
4348

44-
**NOTE:** If you have multiple enums deriving `Events`, these will need to be in separate modules since there's some common boilerplate types that are included currently (that will be moved into another crate at some point).
49+
**NOTE:** If you have multiple enums deriving `Events`, these will need to
50+
be in separate modules since there's some common boilerplate types that are
51+
included currently (that will be moved into another crate at some point).
4552

46-
And if you're using a plugin on the frontend and want bindings generated for it, you can do so by defining a trait for it, e.g:
53+
And if you're using a plugin on the frontend and want bindings generated for
54+
it, you can do so by defining a trait for it, e.g:
4755

4856
```rust
4957
pub mod someplugin {
@@ -55,7 +63,16 @@ I couldn't find a comfortable way of defining commands that would maintain type
5563
}
5664
```
5765

58-
**NOTE:** If you have multiple traits implementing `invoke_bindings` they'll each need to be in their own `mod` since an `invoke` WASM binding will be derived in scope of where the trait is defined (this will be moved into another crate at some point).
66+
**NOTE:** You can find the `cmd_prefix` and plugin API by looking at the
67+
[guest-js](https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/clipboard-manager/guest-js/index.ts)
68+
bindings and [Rust
69+
source](https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/clipboard-manager/src/commands.rs)
70+
for the plugin(s) you're using.
71+
72+
**NOTE:** If you have multiple traits implementing `invoke_bindings` they'll
73+
each need to be in their own `mod` since an `invoke` WASM binding will be
74+
derived in scope of where the trait is defined (this will be moved into
75+
another module at some point).
5976

6077
2. Import the commands trait into your Tauri backend and wrap your command definitions in the `impl_trait` macro, e.g:
6178

@@ -69,7 +86,18 @@ I couldn't find a comfortable way of defining commands that would maintain type
6986
});
7087
```
7188

72-
This will define a shadow struct with an `impl Commands` block with all the functions passed into the macro minus any fn generics or arguments where the type starts with `tauri::`, and spits out the actual fns untouched. The Rust compiler will then emit helpful errors if the defined commands are different (after being processed) from those in the trait, yay!
89+
This will define a new struct named `__ImplCommands` with an `impl Commands
90+
for __ImplCommands` block with all the fns passed into the macro (minus any
91+
fn generics or arguments where the type starts with `tauri::`), and spits
92+
out the actual fns untouched. The Rust compiler will then emit helpful
93+
errors if the defined commands are different (after being processed) from
94+
those in the trait, yay!
95+
96+
**NOTE:** The crudeness here is due to `#[tauri::command]`s needing to be
97+
top level fns and potentially having additional arguments in the siganture.
98+
And while I can imagine a way of abstracting this out of the API (so this
99+
could be a regular `impl` block), this was the easiest thing and works
100+
without changing much about how the commands are defined.
73101

74102
3. Import the event enum into your Tauri backend if you wish to emit events from there, e.g.:
75103

0 commit comments

Comments
 (0)