Expand description
Domain identifier newtypes for BO4E energy-market entities.
Every identifier:
- validates its input at construction time (never panics)
- stores the validated string as a
Box<str>(compact, immutable) - implements
Display,FromStr,TryFrom<&str>,TryFrom<String>,Into<String>,AsRef<str>,Borrow<str>,Deref<Target = str>, andDebug,Clone,Hash,Eq,Ord— none of them behind a feature flag, because they are the minimum an EDIFACT encoder or decoder needs - adds
Serialize/Deserializewith theserdefeature, routed through the same constructor
Structural validation always runs at construction. The validate feature
additionally derives garde rules that re-run the same function, so a
Validated<Marktlokation> re-checks every nested identifier through garde’s
report API.
§What each type validates
Section numbers refer to the BDEW Anwendungshilfe “Identifikatoren in der Marktkommunikation” v1.2 (7 February 2025).
| Type | Always validated | Reference |
|---|---|---|
MaloId | 11 digits, first digit 1–9, §8.1 check digit | BDEW §3 |
MeloId | 33 chars, first 2 uppercase ASCII (country code), rest alphanumeric | No checksum defined |
Zaehlpunktbezeichnung | the same 33 chars — a Zählpunkt that is not a Messlokation | MaBiS; BDEW AWH BK6-20-160 §1.6.2 |
MarktpartnerId | 13 digits — check digit not enforced, see below | BDEW §2 |
Lokationsbuendelcode | 13 digits, §8.1 check digit — which Lokationsbündelstruktur | EDI@Energy Codeliste Lokationsbündelstrukturen v1.0 |
LokationsbuendelObjektcode | 13 digits, §8.1 check digit — where in it an object sits | EDI@Energy Codeliste Lokationsbündelstrukturen v1.0 |
NeloId | Codetyp 'E' + 9 [A-Z0-9] + §8.2 check digit | BDEW §4 (BK6-22-128) |
NebeId | Codetyp 'F' + 9 [A-Z0-9] + §8.2 check digit | BDEW §5 (BK6-22-300, BK8-22/010-A) |
CrId | Codetyp 'A' + 9 [A-Z0-9] + §8.2 check digit | BDEW §6.5/§6.6 — Cluster Ressource |
SgId | Codetyp 'B' + 9 [A-Z0-9] + §8.2 check digit | BDEW §6.4/§6.6 — Steuergruppe |
SrId | Codetyp 'C' + 9 [A-Z0-9] + §8.2 check digit | BDEW §6.3/§6.6 — Steuerbare Ressource |
TrId | Codetyp 'D' + 9 [A-Z0-9] + §8.2 check digit | BDEW §6.2/§6.6 — Technische Ressource |
PaketId | Codetyp 'P9' + 8 [A-Z0-9] + §8.2 check digit | BDEW §7 — Netzbetreiberwechsel |
EicCode | 16 chars, uppercase alphanumeric + -, ENTSO-E check char | ENTSO-E EIC Reference Manual |
BilanzkreisId | 16-char EIC restricted to object type 'X' (Party) | GaBi Gas BK7-14-020, MABIS BK6-06-009 |
BilanzierungsgebietId | 16-char EIC restricted to object type 'Y' (Area) | MABIS BK6-06-009 |
ObisCode | [A-B:]C.D[.E][*F] format | IEC 62056-61 (C=0 permitted) |
AkivId | 1–36 printable ASCII chars | BDEW WiM AHB BK6-24-174 |
TranchennummerId | 1–6 decimal digits, no leading zeros (0–999 999) | MABIS PID 13003 (BK6-06-009) |
Iban | 15–34 chars, registered per-country length, MOD-97-10 check digits | ISO 13616 / ISO 7064 |
Bic | 8 or 11 chars, letters in the institution and country codes | ISO 9362 — no checksum defined |
§Helper types beside the identifiers
Not every type here is an identifier. EicType, MaloVergabestelle,
MpIdAuthority and ObisComponents are facts read out of an
identifier, returned by its accessors. Zaehlpunktart and Zaehlpunkt
are the exception that proves the rule: a Zählpunktart cannot be read out of
a Zaehlpunktbezeichnung — a Zählpunkt (eMob) and a MeloId are
indistinguishable as strings — so it has to be carried alongside, and
Zaehlpunkt::as_melo_id is the narrowing that refuses without it.
§The two BDEW check-digit procedures
Chapter 8 defines two, and they are the same arithmetic — §8.1 for numeric
identifiers, §8.2 (the ASCII-Verfahren, where A–Z map to their ASCII
codes) for alphanumeric ones. A digit maps identically under both, so §8.1 is
§8.2 restricted to numeric input, and this crate implements it once.
MarktpartnerId is the exception that enforces none: an MP-ID may carry
either the §8.1 digit or a GS1/EAN-13 one, and the leading digits do not
reliably separate them. See its own docs for the opt-in checks.
§Where Iban and Bic are not used
Zahlungsinformation keeps both fields as String: it hangs off Rechnung
and nothing else, so a newtype refusing a masked IBAN — DE89 **** **** 3000, routine on an invoice — would take the whole invoice with it.
Zahlungsinformation::iban_checked() costs the caller the field instead.
Modules§
- marktpartner_
id_ as_ i64 serde - Serde adapter module for encoding
MarktpartnerIdas a JSON integer (i64). - schema
schemarsorutoipa - What each identifier looks like on the wire, for the schema generators.
Structs§
- AkivId
- Aktivierungs-ID (AkivId): identifier for a Redispatch 2.0 activation event.
- Bic
- A Business Identifier Code (ISO 9362) — the SWIFT code of a financial institution.
- Bilanzierungsgebiet
Id - Bilanzierungsgebiet-ID: a 16-character EIC code with object type
'Y'(Area). - Bilanzkreis
Id - Bilanzkreis-ID: a 16-character EIC code with object type
'X'(Party). - CrId
- Cluster-Ressource-ID (CR-ID) — identifies a Cluster Ressource in Redispatch 2.0.
- EicCode
- Energy Identification Code (EIC): 16-character code issued by ENTSO-E.
- Iban
- An International Bank Account Number (ISO 13616), checksum-verified.
- Lokationsbuendel
Objektcode - Objekt-Code — where in a Lokationsbündelstruktur one object sits.
- Lokationsbuendelcode
- Code der Lokationsbündelstruktur — which bundle structure a Netzanschluss has.
- MaloId
- Marktlokations-ID (MaLo-ID) — identifies a Marktlokation or Tranche.
- Marktpartner
Id - Marktpartner-ID (MP-ID) — identifies a market participant in one role and one commodity.
- MeloId
- Messlokations-ID (MeLo-ID): 33-character string.
- NebeId
- Netzbereich-ID (NeBe-ID) — identifies a Netzbereich (grid area).
- NeloId
- Netzlokations-ID (NeLo-ID) — identifies a Netzlokation (grid location).
- Obis
Code - OBIS identifier (IEC 62056-61 / BDEW): compact reference for metering values.
- Obis
Components - Parsed representation of an OBIS identifier.
- PaketId
- Paket-ID — identifies the set of locations affected by a Netzbetreiberwechsel (change of grid operator).
- SgId
- Steuergruppen-ID (SG-ID) — identifies a Steuergruppe in Redispatch 2.0.
- SrId
- Steuerbare-Ressource-ID (SR-ID) — identifies a Steuerbare Ressource in Redispatch 2.0.
- TrId
- Technische-Ressource-ID (TR-ID) — identifies a Technische Ressource in Redispatch 2.0 (a physical generation or consumption unit).
- Tranchennummer
Id - Tranchennummer-ID: 1–6 digit numeric identifier for a billing tranche.
- Zaehlpunkt
- A Zählpunktbezeichnung together with what it names.
- Zaehlpunktbezeichnung
- A 33-character Zählpunktbezeichnung that is not (necessarily) a Messlokations-ID.
Enums§
- EicType
- The ENTSO-E EIC object type, encoded in position 3 (index 2) of the code.
- Malo
Vergabestelle - Issuing office (Vergabestelle) encoded in the first digit of a MaLo-ID.
- MpId
Authority - The authority that issued a
MarktpartnerId, derived from its first two digits. - Zaehlpunktart
- Which kind of point a
Zaehlpunktbezeichnungnames.
Constants§
- AKIV_
ID_ MAX_ LEN - Maximum length for an Aktivierungs-ID.
36 accommodates UUID-format activation IDs (e.g.
550e8400-e29b-41d4-a716-446655440000); EDIFACT DE1004 supports up to 35 chars but BDEW WiM AHB BK6-24-174 permits UUID-style identifiers in UTILTS PID 55168 (RFF+ACDreference field). - IBAN_
MAX_ LEN - Maximum IBAN length permitted by ISO 13616.
- IBAN_
MIN_ LEN - Shortest IBAN in the ISO 13616 registry (Norway).
- TRANCHENNUMMER_
MAX - Maximum numeric value for a
TranchennummerId(6 digits → 999 999).
Functions§
- identifier_
deser_ failure_ count serde - Returns the total number of identifier deserialization validation failures observed in this process (across all identifier types).