Expand description
Tauri-Interop is a library that provides macros to improve developing tauri apps with a rust frontend by generating frontend implementation out of the backend definitions.
The main macros intended to be used are:
- command, which is intended to be used as replacement to tauri::command
- Event, that provides an easier usage of the Events feature of tauri
- derives event::Listen when compiling to wasm and event::Emit otherwise
Additionally, some QOL macros (host_usage and wasm_usage) are provided that reduce some drawbacks when simultaneously compiling to wasm and the host architecture.
§Explanation and Examples
Detail explanations and example can be found on the respected traits or macros. Some examples are ignored because they are only valid when compiling to wasm.
§Note
The library uses resolver 2 features to allow easy inclusion without configuration. When working with virtual workspaces the resolver defaults to 1 in which case it is required to set the resolver manually to version 2, otherwise the target specific compilation will not resolve correctly. When the wrong resolver is used, an error should state that the event::Listen trait is missing.
Modules§
- command
- wrapped bindings for easier use in the generated wasm commands
- event
event
- event traits and overall logic for event emitting and listening
Macros§
- collect_
commands Non- target_family="wasm"
- Collects all commands annotated with
tauri_interop::command
and provides these with aget_handlers()
in the current mod - combine_
handlers Non- target_family="wasm"
- Combines multiple modules containing commands
- host_
usage - Simple macro to include multiple imports (seperated by
|
) not in wasm - wasm_
usage - Simple macro to include multiple imports (seperated by
|
) only in wasm
Attribute Macros§
- binding
target_family="wasm"
- Generates the wasm counterpart to a defined
tauri::command
- command
- Conditionally adds the macro binding or
tauri::command
to a struct - commands
Non- target_family="wasm"
- Marks a mod that contains commands
Derive Macros§
- Emit
event
- Generates a default
Emit
implementation for the given struct. - Emit
Field event
- Generates a default
EmitField
implementation for the given struct. - Event
event
- Conditionally adds Listen or Emit to a struct.
- Listen
event
- Generates a default
Listen
implementation for the given struct. - Listen
Field event
- Generates a default
ListenField
implementation for the given struct.