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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! `dvgw-edi` — DVGW EDIFACT for the German gas transport and balancing market.
//!
//! Parses, validates and writes the DVGW-governed formats used in gas balancing
//! (`GaBi` Gas 2.1, `BNetzA` BK7-24-01-008). The DVGW counterpart to `edi-energy`,
//! which covers the BDEW EDI@Energy retail layer.
//!
//! # The one thing to know first
//!
//! **A DVGW message does not name itself in `UNH`.** Every format is a subset of
//! a UN/EDIFACT D.07A message, so `UNH` carries the *carrier* — `ORDERS` or
//! `ORDRSP` — and `BGM` C002 DE 1001 carries the message:
//!
//! ```text
//! UNH+1+ORDERS:D:07A:UN:DVGW18' ← the carrier
//! BGM+01G::332+NOMINT00052' ← *this* says NOMINT
//! DTM+Z05:0:805' ← timestamps below are UTC
//! DTM+137:201801042056:203' ← message date/time
//! DTM+Z01:201801050400201801060400:719' ← Gültigkeitszeitraum = the gas day
//! RFF+Z13:70030' ← Prüfidentifikator
//! ```
//!
//! Matching `UNH` against `"NOMINT"` therefore rejects every conformant message.
//! Identity here is resolved from [`DvgwDocument`], with the carrier as a
//! cross-check.
//!
//! # Supported formats
//!
//! | Message | Carrier | Document codes (`BGM` DE 1001) | Prüfidentifikatoren |
//! |---|---|---|---|
//! | **ALOCAT** — Allokationsnachricht | `ORDRSP` | `X1G X2G X3G X4G X5G X6G X7G XBG` | 70001–70023 |
//! | **NOMINT** — Nominierung | `ORDERS` | `01G 55G Y1G Y6G Y7G` | 70030–70034 |
//! | **NOMRES** — Nominierungsantwort | `ORDRSP` | `07G 08G 19G 20G Y2G` | 70035–70039 |
//! | **SSQNOT** — Mehr-/Mindermengenmeldung | `ORDRSP` | `BAG` | 70095–70096 |
//!
//! `CONTRL` and `APERAK` acknowledge DVGW interchanges but are BDEW formats;
//! they live in `edi-energy` and are not reimplemented here.
//!
//! # Quick start
//!
//! ```rust,no_run
//! use dvgw_edi::{DvgwMessageType, DvgwPlatform};
//!
//! # let raw: &[u8] = b"";
//! let platform = DvgwPlatform::default();
//! for result in platform.parse_interchange(raw) {
//! let msg = result?;
//! println!("{} ({})", msg.message_type, msg.document.description());
//!
//! // The gas day is DTM+Z01, decoded through its own format code.
//! if let Some(period) = msg.validity_period {
//! println!(" Gastag {period}");
//! }
//! // A LOC group carries a time series, not one value.
//! for qty in msg.quantities() {
//! println!(" {:?} {:?}", qty.value, qty.period);
//! }
//! if msg.message_type == DvgwMessageType::Nomint {
//! // RFF+AGO — the nomination a re-nomination corrects. A NOMRES has no
//! // such reference and is paired on the business key instead.
//! println!(" korrigiert {:?}", msg.original_nomination_ref());
//! }
//!
//! let report = DvgwPlatform::validate_message(&msg);
//! for issue in report.errors() {
//! eprintln!(" {issue}");
//! }
//! }
//! # Ok::<(), dvgw_edi::Error>(())
//! ```
//!
//! # Market roles
//!
//! | Role | Abbreviation |
//! |---|---|
//! | Fernleitungsnetzbetreiber | FNB |
//! | Verteilnetzbetreiber | VNB |
//! | Bilanzkreisverantwortlicher | BKV |
//! | Marktgebietsverantwortlicher | MGV |
//!
//! # Regulatory references
//!
//! - **§ 20 Abs. 3 `EnWG`** — Festlegungskompetenz for gas network access and balancing
//! - **`BNetzA` BK7-24-01-008** — `GaBi` Gas 2.1
//! - **Kooperationsvereinbarung Gas (`KoV`)** — nomination and allocation deadlines
//! - DVGW-Nachrichtenbeschreibungen: <https://www.dvgw-sc.de/leistungen/it-dienstleistungen/datenaustausch-gas>
//!
//! # Relationship to other crates
//!
//! | Crate | Layer |
//! |---|---|
//! | `dvgw-edi` | EDIFACT parsing / validation / writing — **this crate** |
//! | `mako-gabi-gas` | `GaBi` Gas process engine (workflows, deadlines) |
//! | `edi-energy` | BDEW EDI@Energy formats (UTILMD, MSCONS, APERAK, …) |
/// The typed message model: positions, locations, quantities and parties.
/// SSQNOT read as one Mehr-/Mindermengen record.
pub use ;
pub use ;
pub use ;
pub use Error;
pub use DvgwMessage;
pub use ;
pub use ;
pub use ;
pub use ;
pub use DvgwVersion;
pub use ;