Expand description
§typebridge
Cross-Language Type Synchronization SDK for Rust.
Define your types once in Rust. Get perfectly matching types in TypeScript, Python, Go, Swift, Kotlin, GraphQL, and JSON Schema — automatically, forever.
§Overview
typewriter eliminates the tedious work of keeping types in sync across languages.
Annotate your Rust structs with #[derive(TypeWriter)] and #[sync_to(...)],
and the types are automatically generated in all target languages on every build.
§Quick Start
ⓘ
use typebridge::TypeWriter;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, TypeWriter)]
#[sync_to(typescript, python, go)]
pub struct UserProfile {
pub id: Uuid,
pub email: String,
pub age: Option<u32>,
}On cargo build, this generates:
./generated/typescript/user-profile.ts— TypeScript interface./generated/typescript/user-profile.schema.ts— Zod schema./generated/python/user_profile.py— Python Pydantic model./generated/go/user_profile.go— Go struct
§Supported Languages
| Language | Feature Flag | Output |
|---|---|---|
| TypeScript | typescript (default) | .ts interfaces + Zod schemas |
| Python | python (default) | .py Pydantic models |
| Go | go (default) | .go structs |
| Swift | swift (default) | .swift Codable structs |
| Kotlin | kotlin (default) | .kt data classes |
| GraphQL | graphql (default) | .graphql SDL |
| JSON Schema | json_schema (default) | .schema.json |
§Feature Flags
Disable languages you don’t need to reduce compile times:
[dependencies]
typebridge = { version = "0.5.0", default-features = false, features = ["typescript", "python"] }§CLI
For project-wide generation, drift checking, and watch mode:
cargo install typebridge-cli
typewriter generate --all # Generate all types
typewriter check --ci # Check for drift
typewriter watch # Watch for changesSee typebridge_cli for more.
Modules§
- config
- Re-export core types for advanced usage.
Configuration parsing for
typewriter.toml. - ir
- Re-export core types for advanced usage. Internal Representation (IR) for typewriter.
- mapper
- Re-export core types for advanced usage.
The
TypeMappertrait — the core contract every language emitter must implement. - naming
- Re-export core types for advanced usage. File naming utilities for converting type names to different case styles.
Structs§
- EnumDef
- Re-export core types for advanced usage. A complete enum definition in the IR.
- Field
Def - Re-export core types for advanced usage. A single field inside a struct.
- Struct
Def - Re-export core types for advanced usage. A complete struct definition in the IR.
- Typewriter
Config - Re-export core types for advanced usage.
Top-level configuration from
typewriter.toml. - Variant
Def - Re-export core types for advanced usage. A single enum variant.
Enums§
- Enum
Repr - Re-export core types for advanced usage. How the enum is represented in JSON (mirrors serde’s options).
- File
Style - Re-export core types for advanced usage. Supported file naming styles.
- Language
- Re-export core types for advanced usage. The target languages that typewriter can generate code for.
- Primitive
Type - Re-export core types for advanced usage. Rust primitive types that map to language-specific equivalents.
- TypeDef
- Re-export core types for advanced usage. Top-level item — either a struct or an enum.
- Type
Kind - Re-export core types for advanced usage. Every Rust type is mapped to one of these variants.
- Variant
Kind - Re-export core types for advanced usage. The kind of data an enum variant carries.
Traits§
- Type
Mapper - Re-export core types for advanced usage. The core trait that every language emitter must implement.
Functions§
- to_
file_ style - Re-export core types for advanced usage. Convert a PascalCase name to the specified file style.
Derive Macros§
- Type
Writer - Re-export the
TypeWriterderive macro. Derive macro for typewriter type synchronization.