Expand description
§gear-mesh
Next-generation Rust to TypeScript type definition sharing library.
§Features
- Type Conversion: Automatic Rust → TypeScript type conversion
- Branded Types: Newtype pattern → TypeScript Branded Types
- Doc Comments: Rust doc comments → JSDoc
- BigInt Support: Automatic i64/u64 → bigint conversion
- Validation: Runtime validation function generation
- Serde Integration: Full serde attribute support
§Quick Start
use gear_mesh::GearMesh;
#[derive(GearMesh)]
#[gear_mesh(branded)]
struct UserId(i32);
#[derive(GearMesh)]
struct User {
id: UserId,
name: String,
email: Option<String>,
}Generated TypeScript:
type Brand<T, B> = T & { readonly __brand: B };
export type UserId = Brand<number, "UserId">;
export const UserId = (value: number): UserId => value as UserId;
export interface User {
id: UserId;
name: string;
email?: string | null;
}§CLI Usage
Install the CLI tool:
cargo install gear-mesh-cliGenerate TypeScript definitions:
gear-mesh generate --input src --output bindings
gear-mesh watch --input src --output bindings§Configuration
Create gear-mesh.toml:
[generator]
use_bigint = true
generate_branded = true
generate_jsdoc = true
[paths]
input = "src"
output = "bindings"Re-exports§
pub use inventory;
Modules§
Macros§
- export_
types - Export types macro for compile-time TypeScript generation
Structs§
- Branded
Type Generator - Generator for Branded Types
- DocComment
- ドキュメントコメント
- Enum
Type - 列挙型
- Enum
Variant - 列挙型のバリアント
- Field
Info - フィールド情報
- Gear
Mesh Type - gear-mesh型の中間表現
- Generator
Config - 生成設定
- Generic
Param - ジェネリクスパラメータ
- Newtype
Type - 新型パターン
- Serde
Field Attrs - serdeフィールド属性
- Struct
Type - 構造体型
- Type
Attributes - 型の属性
- Type
Info - Type information for automatic collection via inventory
- TypeRef
- 型参照
- Type
Script Generator - TypeScript生成器
- Validation
Generator - Generator for Zod validation schemas
Enums§
- Enum
Representation - 列挙型の表現方式
- Primitive
Type - プリミティブ型
- Type
Kind - 型の種類
- Validation
Rule - バリデーションルール
- Variant
Content - バリアントの内容
Traits§
- Gear
Mesh Export - Trait for types that can be exported to TypeScript
Functions§
- extract_
type_ dependencies - Extract all custom type names referenced by a type
- generate_
types - Generate TypeScript definitions for all registered types
- generate_
types_ to_ dir - Generate TypeScript definitions to separate files
- register_
output - Register an output path and generate types if this is the first time
Derive Macros§
- Gear
Mesh - GearMesh derive macro