Skip to main content

Crate typebridge

Crate typebridge 

Source
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, and Kotlin — automatically, forever.

§Usage

use typebridge::TypeWriter;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, TypeWriter)]
#[sync_to(typescript, python)]
pub struct UserProfile {
    pub id: Uuid,
    pub email: String,
    pub age: Option<u32>,
}
// On cargo build, generates:
// ✅ ./generated/typescript/user-profile.ts
// ✅ ./generated/python/user_profile.py

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 TypeMapper trait — 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.
FieldDef
Re-export core types for advanced usage. A single field inside a struct.
StructDef
Re-export core types for advanced usage. A complete struct definition in the IR.
TypewriterConfig
Re-export core types for advanced usage. Top-level configuration from typewriter.toml.
VariantDef
Re-export core types for advanced usage. A single enum variant.

Enums§

EnumRepr
Re-export core types for advanced usage. How the enum is represented in JSON (mirrors serde’s options).
FileStyle
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.
PrimitiveType
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.
TypeKind
Re-export core types for advanced usage. Every Rust type is mapped to one of these variants.
VariantKind
Re-export core types for advanced usage. The kind of data an enum variant carries.

Traits§

TypeMapper
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§

TypeWriter
Re-export the TypeWriter derive macro. Derive macro for typewriter type synchronization.