tauri_ts_generator/
lib.rs

1//! # tauri-ts-generator
2//!
3//! A CLI tool and library for generating TypeScript bindings from Tauri commands.
4//!
5//! This crate scans your Rust code for `#[tauri::command]` macros and automatically generates:
6//! - **TypeScript interfaces** for your Rust structs and enums.
7//! - **TypeScript wrapper functions** to invoke your commands.
8//!
9//! It is designed to ensure type safety between your Rust backend and TypeScript frontend,
10//! reducing boilerplate and runtime errors.
11//!
12//! ## Features
13//!
14//! - **Automated Parsing**: Uses `syn` to parse Rust AST.
15//! - **Async Support**: Correctly handles `async` commands.
16//! - **Type Mapping**: Converts Rust types to their TypeScript equivalents.
17//! - **Custom Types**: Supports `struct` and `enum` with `serde` serialization.
18//!
19//! ## Usage
20//!
21//! Although primarily used as a CLI tool, you can also use it as a library:
22//!
23//! ```rust,no_run
24//! use tauri_ts_generator::config::Config;
25//! use tauri_ts_generator::pipeline::Pipeline;
26//!
27//! fn main() -> anyhow::Result<()> {
28//!     let config = Config::default_config();
29//!     let pipeline = Pipeline::new(false);
30//!     pipeline.run(&config)?;
31//!     Ok(())
32//! }
33//! ```
34
35pub mod cargo_expand;
36pub mod cli;
37pub mod config;
38pub mod generator;
39pub mod known_types;
40pub mod models;
41pub mod parser;
42pub mod pipeline;
43pub mod resolver;
44pub mod scanner;
45pub mod utils;
46
47// Re-export the TS derive macro for user convenience
48pub use tauri_ts_generator_derive::TS;
49
50