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
//! `dvgw-edi` — DVGW EDIFACT format parser for the German gas transport and
//! balancing market.
//!
//! This crate implements parsing of **DVGW-governed EDIFACT formats** used in
//! gas network balancing (`GaBi Gas 2.1`, `BNetzA` BK7-24-01-008). It is the DVGW
//! counterpart to the `edi-energy` crate which covers BDEW EDI@Energy.
//!
//! # Supported formats
//!
//! | Message | Version | Valid from | UN/EDIFACT base | Description |
//! |---|---|---|---|---|
//! | `ALOCAT` | 5.11a | 2024-10-01 | D03A | Gas quantity allocation (Allokationsnachricht) |
//! | `NOMINT` | 4.6 FK | 2026-02-01 | D01B | Nomination integration (Nominierungsintegration) |
//! | `NOMRES` | 4.7 FK | 2026-02-01 | D01B | Nomination response (Nominierungsantwort) |
//!
//! # Quick start
//!
//! ```rust,no_run
//! use dvgw_edi::{DvgwPlatform, AnyDvgwMessage, DvgwMessage};
//!
//! # let input: &[u8] = b"";
//! let msg = DvgwPlatform::default().parse(input)?;
//!
//! if let AnyDvgwMessage::Nomint(nomint) = msg {
//! println!("nomination ref: {:?}", nomint.nomination_ref);
//! println!("sender EIC: {:?}", nomint.sender_eic());
//! for qty in &nomint.quantities {
//! println!(" location={} qty={} {}", qty.location_code, qty.quantity,
//! qty.unit.as_deref().unwrap_or("?"));
//! }
//! }
//! # Ok::<(), dvgw_edi::Error>(())
//! ```
//!
//! # Market roles
//!
//! | Role | Abbreviation | Description |
//! |---|---|---|
//! | Fernleitungsnetzbetreiber | FNB | Gas transmission system operator |
//! | Verteilnetzbetreiber | VNB | Gas distribution system operator |
//! | Bilanzkreisverantwortlicher | BKV | Balance responsible party |
//! | Marktgebietsverantwortlicher | MGV | Market area manager |
//!
//! # Message routing
//!
//! DVGW messages do not use a BGM Prüfidentifikator. Routing uses the
//! combination of message type and direction qualifier from the NAD+MS/MR
//! role codes. Use [`AnyDvgwMessage::detect_pid`] to obtain the synthetic PID
//! for registration with the `mako-engine` PID router:
//!
//! ```rust,no_run
//! use dvgw_edi::DvgwPlatform;
//!
//! # let input: &[u8] = b"";
//! let msg = DvgwPlatform::default().parse(input)?;
//! // BKV → FNB nomination → synthetic PID 90011
//! let pid = msg.detect_pid(Some("Z01"));
//! # Ok::<(), dvgw_edi::Error>(())
//! ```
//!
//! Use [`AnyDvgwMessage::as_trait`] to access the [`message::DvgwMessage`]
//! trait methods for the sender/receiver EIC codes.
//!
//! # Regulatory references
//!
//! - **§20 Abs. 3 `EnWG`** — Festlegungskompetenz for gas network access and balancing
//! - **`BNetzA` BK7-24-01-008** — `GaBi` Gas 2.1 ruling (current)
//! - **`DVGW G 685`** — technical standard for gas metering and allocation
//! - DVGW AHBs and MIGs: <https://www.dvgw-sc.de/leistungen/it-dienstleistungen/datenaustausch-gas>
//!
//! # Relationship to other crates
//!
//! | Crate | Layer |
//! |---|---|
//! | `dvgw-edi` | EDIFACT parsing (ALOCAT, NOMINT, NOMRES) — **this crate** |
//! | `mako-gabi-gas` | GaBi Gas process engine (Workflow, deadline handling) |
//! | `mako-engine` | Event-sourced workflow runtime |
//! | `edi-energy` | BDEW EDI@Energy formats (UTILMD, MSCONS, APERAK, …) |
/// Concrete DVGW message type structs.
pub use AnyDvgwMessage;
pub use Error;
pub use DvgwMessage;
pub use DvgwMessageType;
pub use DvgwPlatform;
pub use ;
pub use DvgwVersion;