Specta
Export Rust types to TypeScript, Swift, Go, OpenAPI, and other languages automatically.
Repository Health
Technical Analysis
Specta is a Rust crate that reflects your Rust structs, enums, and function signatures at compile time and exports matching type definitions to other languages — TypeScript and Swift are production-ready today, with Go, C#, Java, Kotlin, OpenAPI, JSON Schema, Zod, Python, and Rust-to-Rust exporters at varying levels of maturity. Types opt in via a #[derive(Type)] macro, after which any of Specta’s per-language exporter crates (specta-typescript, specta-swift, etc.) can turn the reflected type graph into idiomatic target-language code.
Specta is the foundational type-reflection layer underneath higher-level tools like tauri-specta (typed Tauri commands) and rspc (typed RPC APIs), letting Rust backends and their non-Rust frontends or clients share one canonical type definition instead of hand-duplicating DTOs.
What You Get
- A
#[derive(Type)]macro (viaspecta-macros) that reflects struct/enum shape, generics, and doc comments into a language-agnostic type graph - Function-signature reflection so Specta-aware tools (like tauri-specta) can generate typed call wrappers, not just data types
- A family of per-language exporter crates:
specta-typescriptandspecta-swift(stable), plusspecta-go,specta-csharp,specta-java,specta-kotlin,specta-jsonschema,specta-zod,specta-python,specta-openapi, andspecta-rust(partial/in-progress) - Wide coverage of common Rust ecosystem types (serde, chrono, uuid, etc.) out of the box so exported types match idiomatic Serde serialization
- Type inference support for functions returning
impl Type, avoiding explicit type annotations in many cases
Common Use Cases
- Generating TypeScript types for a Rust backend’s API/IPC layer consumed by a JS/TS frontend (directly, or via
tauri-specta) - Building a typed end-to-end RPC framework on top of Specta’s reflection (as
rspcdoes) - Exporting OpenAPI or JSON Schema documents describing a Rust API’s request/response types
- Sharing one canonical Rust type definition across multiple client languages (Swift, Kotlin, Go, Python) in a multi-platform app
Under The Hood
Architecture: The core specta crate defines a language-agnostic DataType/Type model (src/datatype.rs, src/type.rs) that a #[derive(Type)] proc macro (specta-macros) populates by reflecting Rust struct/enum definitions and function signatures (src/function.rs); each target language then lives in its own downstream crate (e.g. specta-typescript) that walks this shared DataType graph and renders it into that language’s syntax, keeping the reflection core decoupled from any single output format. Tech Stack: Pure Rust workspace (Cargo.toml with members set to specta, specta-*, tests, and examples) using proc-macros for the derive, with per-exporter crates depending only on the core specta crate plus target-format-specific logic (e.g. specta-jsonschema implements JSON Schema draft 7/2019-09/2020-12). Code Quality: The workspace enables strict Clippy lints (unwrap_used, panic, todo all set to warn) across all crates, has a dedicated tests/ workspace member with schema and typecheck fixtures (including a zod-typecheck suite), and documents implementation-status maturity per exporter (2 production-ready, 9 partial) directly in the README rather than overstating completeness. API Design: The primary surface is a single #[derive(Type)] attribute plus optional per-field attributes for renaming/skipping, mirroring Serde’s derive ergonomics closely so Rust developers already familiar with #[derive(Serialize)] need minimal new mental model to adopt Specta.
Used by 3 apps in this directory
Cap
Team Chat · Video Conferencing
Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.
Epicenter
Knowledge Management · Note Taking · Developer Tools
A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.
Handy
Productivity
Free, offline, open-source speech-to-text that pastes directly into any app on Windows, macOS, and Linux.