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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! ISO 20022 financial message toolkit.
//!
//! `mx20022` is an umbrella crate that re-exports the four workspace
//! components needed to read, write, validate, and translate
//! ISO 20022 messages and SWIFT MT messages:
//!
//! - [`model`] — strongly-typed message structs generated from the
//! official XSD schemas (`pacs`, `pain`, `camt`, `head`).
//! - [`parse`] — XML deserialization, serialization, and envelope
//! message-type detection.
//! - [`validate`] — field-level rule, schema, and scheme (`FedNow` / SEPA /
//! CBPR+) validation.
//! - [`translate`] — bidirectional MT ↔ MX translation for the supported
//! message pairs (MT103 ↔ pacs.008, MT202 ↔ pacs.009, MT940 ↔ camt.053).
//!
//! See the per-crate docs for full API surface; the [`prelude`] re-exports
//! the items most users need for typical workflows.
//!
//! # Quick start: parse an ISO 20022 XML message
//!
//! ```rust
//! use mx20022::prelude::*;
//! use mx20022::model::generated::pacs::pacs_008_001_13::Document;
//!
//! let xml = r#"<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.13"></Document>"#;
//! let id = detect_message_type(xml).unwrap();
//! assert_eq!(id.family, "pacs");
//! assert_eq!(id.msg_id, "008");
//! assert_eq!(id.version, "13");
//! ```
//!
//! # Quick start: translate MT103 to pacs.008
//!
//! ```rust
//! use mx20022::prelude::*;
//!
//! let raw = "\
//! {1:F01BANKBEBBAXXX0000000000}\
//! {2:I103BANKDEFFXXXXN}\
//! {3:{108:MYREF}}\
//! {4:\n\
//! :20:REF123\n\
//! :23B:CRED\n\
//! :32A:230615EUR1000,00\n\
//! :50K:ACME CORP\n\
//! :59:JANE SMITH\n\
//! :71A:SHA\n\
//! -}\
//! {5:{CHK:ABCDEF1234}}";
//!
//! let mt = mt::parse(raw).unwrap();
//! let mt103 = mt::fields::mt103::parse_mt103(&mt.block4).unwrap();
//! let result = mt103_to_pacs008(&mt103, "MSG-1", "2023-06-15T10:00:00").unwrap();
//! assert!(result.warnings.is_empty() || !result.warnings.is_empty());
//! ```
//!
//! # Quick start: validate a single field
//!
//! ```rust
//! use mx20022::prelude::*;
//!
//! let registry = RuleRegistry::with_defaults();
//! let errors = registry.validate_field(
//! "GB82WEST12345698765432",
//! "/Document/CdtTrfTxInf/CdtrAcct/Id/IBAN",
//! &["IBAN_CHECK"],
//! );
//! assert!(errors.is_empty());
//! ```
pub use mx20022_model as model;
pub use mx20022_parse as parse;
pub use mx20022_translate as translate;
pub use mx20022_validate as validate;
/// Curated re-exports for typical workflows.
///
/// Glob-import this module to get the headline error types, the
/// translation entry-point functions, the SWIFT MT parser, and the
/// validation registry without remembering each sub-crate's path.
///
/// ```
/// use mx20022::prelude::*;
/// ```