Skip to main content

redispatch_xml/
lib.rs

1//! `redispatch-xml` — Redispatch 2.0 XML/XSD format parsing and validation
2//! for the German electricity grid (§§ 13, 13a, 14 EnWG).
3//!
4//! # Domain background
5//!
6//! **Redispatch 2.0** entered into force on **1 October 2021** via the
7//! Netzausbaubeschleunigungsgesetz (NABEG) and requires all German grid
8//! operators to coordinate congestion management across transmission and
9//! distribution networks. It covers:
10//!
11//! - All renewable-energy (EE) and combined heat-and-power (KWK) plants
12//!   with ≥ 100 kW installed capacity
13//! - All installations permanently remote-controllable by a grid operator
14//!   (e.g. via Smart-Meter-Gateway)
15//!
16//! # Format family
17//!
18//! Redispatch 2.0 uses CIM/IEC 62325-based XML documents for the primary data
19//! exchange between TSOs, DSOs, and balance responsible parties. Documents are
20//! validated against BDEW-published XSD schemas (topicGroupId 25 in the BDEW
21//! MaKo document API).
22//!
23//! | Document type | XSD version | Valid from |
24//! |---|---|---|
25//! | `ActivationDocument` | 1.1f | 2025-10-01 |
26//! | `PlannedResourceScheduleDocument` | 1.0f | 2025-10-01 |
27//! | `AcknowledgementDocument` | 1.0f | 2025-10-01 |
28//! | `Stammdaten` | 1.4b | 2025-10-01 |
29//! | `StatusRequest_MarketDocument` | 1.1 | 2025-10-01 |
30//! | `Unavailability_MarketDocument` | 1.1b | 2025-10-01 |
31//! | `Kaskade` | 1.0 | 2025-10-01 |
32//! | `NetworkConstraintDocument` | 1.1b | 2025-10-01 |
33//! | `Kostenblatt` | 1.0d | 2025-10-01 |
34//!
35//! These are **not** EDIFACT. IFTSTA status messages for the Redispatch 2.0
36//! workflow are handled separately by the `edi-energy` crate.
37//!
38//! # Market roles
39//!
40//! | Role | Abbrev. | Description |
41//! |------|---------|-------------|
42//! | Übertragungsnetzbetreiber | ÜNB | Transmission system operator |
43//! | Verteilnetzbetreiber | VNB | Distribution system operator |
44//! | Anlagenbetreiber | ANB | Generation asset operator |
45//! | Direktvermarkter | DV | Direct marketer of renewable energy |
46//! | Bilanzkreisverantwortlicher | BKV | Balance responsible party |
47//!
48//! # Quick start
49//!
50//! ```rust,no_run
51//! use redispatch_xml::{parse, Document};
52//!
53//! let xml: &[u8] = b"<ActivationDocument xmlns=\"urn:entsoe.eu:wgedi:errp:activationdocument:5:0\">...</ActivationDocument>";
54//! match parse(xml) {
55//!     Ok(Document::Activation(doc)) => println!("Got ACO/ACR/AAR: {:?}", doc.document_type),
56//!     Ok(other) => println!("Other document type: {:?}", other.document_type()),
57//!     Err(e) => eprintln!("Parse error: {e}"),
58//! }
59//! ```
60//!
61//! # Regulatory references
62//!
63//! - **§§ 13, 13a, 14 EnWG** — statutory basis for grid congestion management
64//! - **NABEG 2019** — introduced Redispatch 2.0, effective 1 October 2021
65//! - **BNetzA BK6-20-059/060/061** — three BNetzA rulings governing billing
66//!   balance, grid operator coordination, and information provision
67//! - **BDEW XML-Datenformate Redispatch 2.0** — XSD schemas and application
68//!   guidelines published on [bdew-mako.de](https://www.bdew-mako.de)
69
70#![deny(unsafe_code)]
71
72pub mod documents;
73pub mod error;
74mod parse;
75mod serialize;
76pub mod types;
77pub mod validation;
78
79// ── Top-level re-exports ──────────────────────────────────────────────────────
80
81pub use documents::{
82    AcknowledgementDocument, ActivationDocument, DocumentType, Kaskade, Kostenblatt,
83    NetworkConstraintDocument, PlannedResourceScheduleDocument, Stammdaten,
84    StatusRequestMarketDocument, UnavailabilityMarketDocument,
85};
86pub use error::RedispatchXmlError;
87pub use parse::{Document, detect, parse, parse_and_validate, parse_as};
88pub use serialize::{serialize, serialize_as};
89pub use validation::{ValidationResult, ValidationWarning, validate};