Skip to main content

mx20022_codegen/
lib.rs

1//! XSD to Rust code generator for ISO 20022 message types.
2//!
3//! This crate reads ISO 20022 XSD schema files and generates idiomatic Rust
4//! type definitions suitable for serialization with `quick-xml` and `serde`.
5//!
6//! # Architecture
7//!
8//! 1. **`xsd`** — Parse XSD files into an AST ([`xsd::Schema`]).
9//! 2. **`ir`** — Lower the AST into a typed intermediate representation
10//!    ([`ir::TypeGraph`]).
11//! 3. **`emit`** — Render the IR to formatted Rust source code.
12//!
13//! # Quick start
14//!
15//! ```no_run
16//! use mx20022_codegen::{xsd, ir, emit};
17//!
18//! let schema = xsd::parse_str(r#"<xs:schema
19//!     xmlns:xs="http://www.w3.org/2001/XMLSchema"
20//!     targetNamespace="urn:example">
21//!   <xs:element name="Root" type="RootType"/>
22//!   <xs:complexType name="RootType">
23//!     <xs:sequence>
24//!       <xs:element name="Id" type="xs:string"/>
25//!     </xs:sequence>
26//!   </xs:complexType>
27//! </xs:schema>"#).unwrap();
28//!
29//! let graph = ir::lower(&schema).unwrap();
30//! let rust_source = emit::emit(&graph);
31//! println!("{rust_source}");
32//! ```
33
34pub mod emit;
35pub mod ir;
36pub mod xsd;