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
62
63
64
// SPDX-License-Identifier: Apache-2.0
//! Code generation module — Rust source code emission from the validated IR.
//!
//! Generates idiomatic Rust code from a `PhenotypeModule`:
//!
//! - **Singular structs** with public fields (REQ-CODEGEN-002)
//! - **Plural wrapper structs** with collection API (REQ-CODEGEN-003)
//! - **Builder structs** with `build()` validation (REQ-CODEGEN-004)
//! - **`Render` trait** implementations (REQ-CODEGEN-006)
//! - **Union enums** and **namespace enums** (REQ-CODEGEN-007/008)
//! - **`BuildError`** enum (REQ-CODEGEN-005)
//!
//! # Usage
//!
//! ```ignore
//! use phenotyper::codegen;
//! let rust_code = codegen::generate(&module);
//! ```
use cratePhenotypeModule;
// ─── Entry point ────────────────────────────────────────────────────────────
/// Generate Rust source code from a validated `PhenotypeModule`.
///
/// Returns a `String` containing the complete generated Rust module.
/// The output is post-processed with `rustfmt` if available (T-094).
/// Attempt to format Rust source code using `rustfmt`.
///
/// Returns `Some(formatted)` on success, or `None` if `rustfmt` is
/// unavailable or fails (graceful fallback).