tauri_interop/
lib.rs

1//! Tauri-Interop is a library that provides macros to improve developing tauri apps with a rust
2//! frontend by generating frontend implementation out of the backend definitions.
3//!
4//! The main macros intended to be used are:
5//! - [macro@command], which is intended to be used as replacement to [macro@tauri::command]
6//! - [macro@Event], that provides an easier usage of the [Events feature of tauri](https://v2.tauri.app/develop/calling-frontend/)
7//!     - derives [event::Listen] when compiling to wasm and [event::Emit] otherwise
8//!
9//! Additionally, some QOL macros ([host_usage] and [wasm_usage]) are provided that
10//! reduce some drawbacks when simultaneously compiling to wasm and the host architecture.
11//!
12//! ### Explanation and Examples
13//!
14//! Detail explanations and example can be found on the respected traits or macros. Some
15//! examples are ignored because they are only valid when compiling to wasm.
16//!
17//! ### Note
18//!
19//! The library uses resolver 2 features to allow easy inclusion without configuration. When working
20//! with virtual workspaces the resolver defaults to 1 in which case it is required to set the
21//! resolver manually to version 2, otherwise the [target specific compilation](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies)
22//! will not resolve correctly. When the wrong resolver is used, an error should state that the
23//! [event::Listen] trait is missing.
24
25#![feature(trait_alias)]
26#![feature(doc_cfg)]
27#![warn(missing_docs)]
28
29#[cfg(any(target_family = "wasm", doc))]
30#[doc(cfg(target_family = "wasm"))]
31pub use tauri_interop_macro::binding;
32pub use tauri_interop_macro::*;
33#[cfg(not(target_family = "wasm"))]
34#[doc(cfg(not(target_family = "wasm")))]
35pub use tauri_interop_macro::{collect_commands, combine_handlers, commands};
36#[cfg(feature = "event")]
37#[doc(cfg(feature = "event"))]
38pub use tauri_interop_macro::{Emit, EmitField, Event, Listen, ListenField};
39
40/// wrapped bindings for easier use in the generated wasm commands
41pub mod command;
42/// event traits and overall logic for event emitting and listening
43#[cfg(feature = "event")]
44#[doc(cfg(feature = "event"))]
45pub mod event;
46
47#[doc(hidden)]
48pub mod export {
49    pub use log;
50    pub use serde;
51
52    #[cfg(target_family = "wasm")]
53    pub use serde_wasm_bindgen;
54
55    #[cfg(not(target_family = "wasm"))]
56    pub use tauri;
57}
58
59// re-export tauri ipc for usage in the command proc-macro of tauri
60#[doc(hidden)]
61#[cfg(not(target_family = "wasm"))]
62pub use tauri::ipc;