tyzen-macro 0.1.6

Procedural macros for the tyzen crate.
Documentation

Tyzen ⚡

A lightweight, high-performance tool to generate TypeScript type definitions from Rust structs and enums. Perfect for Tauri apps and full-stack Rust/TypeScript projects.

Features

  • 🚀 Lightning Fast: Generates types in milliseconds.
  • 📦 Zero Config: Works out of the box with minimal setup.
  • 🔌 Tauri Integration: First-class support for Tauri commands.
  • 🛠️ Macro-based: Simple #[derive(Type)] and #[command] attributes.
  • 🧩 Extensible: Easily supports custom types like Uuid and Chrono.

Packages

  • tyzen: The core crate containing the logic for type generation.
  • tyzen-macro: Procedural macros for deriving types and marking commands.
  • tyzen-tauri: Specialized integration for Tauri applications.

Quick Start

1. Add Dependencies

Add tyzen to your Cargo.toml:

[dependencies]
tyzen = { version = "0.1.6", path = "../tyzen/tyzen" }

2. Define Your Types

use tyzen::Type;

#[derive(Type)]
pub struct User {
    id: u32,
    username: String,
    email: String,
}

3. Generate TypeScript

fn main() {
    tyzen::generate("bindings.ts");
}

Tauri Support

Tyzen provides a seamless experience for Tauri developers. It not only generates TypeScript types but also automatically collects and registers your commands.

1. Mark your commands

#[tyzen::command]
pub fn create_user(user: User) -> Result<User, String> {
    // ...
}

2. Register all commands automatically

Forget manual registration. Use tyzen_tauri::handler!() to register all marked commands at once:

tauri::Builder::default()
    .invoke_handler(tyzen_tauri::handler!()) // That's it!
    .run(tauri::generate_context!())
    .expect("error while running tauri application");

License

MIT / Apache-2.0