1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! # typewriter-python
//!
//! Python Pydantic v2 / dataclass emitter for the typewriter type sync SDK.
//! Generates `.py` files with Pydantic `BaseModel` classes.
//!
//! ## Type Mappings
//!
//! | Rust Type | Python Type |
//! |-----------|-------------|
//! | `String` | `str` |
//! | `bool` | `bool` |
//! | `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64` | `int` |
//! | `f32`, `f64` | `float` |
//! | `Uuid` | `UUID` |
//! | `DateTime<Utc>` | `datetime` |
//! | `Option<T>` | `Optional[T] = None` |
//! | `Vec<T>` | `list[T]` |
//! | `HashMap<K, V>` | `dict[K, V]` |
//! | Custom struct/enum | Class reference |
//!
//! ## Configuration
//!
//! In `typewriter.toml`:
//!
//! ```toml
//! [python]
//! output_dir = "./generated/python"
//! file_style = "snake_case" # snake_case (default), kebab-case, or PascalCase
//! pydantic_v2 = true # Use Pydantic v2 (default: true)
//! use_dataclass = false # Use @dataclass instead of BaseModel
//! ```
//!
//! ## Example
//!
//! **Rust Input:**
//! ```rust,ignore
//! #[derive(TypeWriter)]
//! #[sync_to(python)]
//! pub struct User {
//! pub id: String,
//! pub email: String,
//! pub age: Option<u32>,
//! }
//! ```
//!
//! **Generated Python:**
//! ```python
//! from pydantic import BaseModel
//! from typing import Optional
//!
//!
//! class User(BaseModel):
//! id: str
//! email: str
//! age: Optional[int] = None
//! ```
pub use PythonMapper;