Skip to main content

Module identifiers

Module identifiers 

Source
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>, and Debug, Clone, Hash, Eq, Ord — none of them behind a feature flag, because they are the minimum an EDIFACT encoder or decoder needs
  • adds Serialize / Deserialize with the serde feature, 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).

TypeAlways validatedReference
MaloId11 digits, first digit 1–9, §8.1 check digitBDEW §3
MeloId33 chars, first 2 uppercase ASCII (country code), rest alphanumericNo checksum defined
Zaehlpunktbezeichnungthe same 33 chars — a Zählpunkt that is not a MesslokationMaBiS; BDEW AWH BK6-20-160 §1.6.2
MarktpartnerId13 digits — check digit not enforced, see belowBDEW §2
Lokationsbuendelcode13 digits, §8.1 check digit — which LokationsbündelstrukturEDI@Energy Codeliste Lokationsbündelstrukturen v1.0
LokationsbuendelObjektcode13 digits, §8.1 check digit — where in it an object sitsEDI@Energy Codeliste Lokationsbündelstrukturen v1.0
NeloIdCodetyp 'E' + 9 [A-Z0-9] + §8.2 check digitBDEW §4 (BK6-22-128)
NebeIdCodetyp 'F' + 9 [A-Z0-9] + §8.2 check digitBDEW §5 (BK6-22-300, BK8-22/010-A)
CrIdCodetyp 'A' + 9 [A-Z0-9] + §8.2 check digitBDEW §6.5/§6.6 — Cluster Ressource
SgIdCodetyp 'B' + 9 [A-Z0-9] + §8.2 check digitBDEW §6.4/§6.6 — Steuergruppe
SrIdCodetyp 'C' + 9 [A-Z0-9] + §8.2 check digitBDEW §6.3/§6.6 — Steuerbare Ressource
TrIdCodetyp 'D' + 9 [A-Z0-9] + §8.2 check digitBDEW §6.2/§6.6 — Technische Ressource
PaketIdCodetyp 'P9' + 8 [A-Z0-9] + §8.2 check digitBDEW §7 — Netzbetreiberwechsel
EicCode16 chars, uppercase alphanumeric + -, ENTSO-E check charENTSO-E EIC Reference Manual
BilanzkreisId16-char EIC restricted to object type 'X' (Party)GaBi Gas BK7-14-020, MABIS BK6-06-009
BilanzierungsgebietId16-char EIC restricted to object type 'Y' (Area)MABIS BK6-06-009
ObisCode[A-B:]C.D[.E][*F] formatIEC 62056-61 (C=0 permitted)
AkivId1–36 printable ASCII charsBDEW WiM AHB BK6-24-174
TranchennummerId1–6 decimal digits, no leading zeros (0–999 999)MABIS PID 13003 (BK6-06-009)
Iban15–34 chars, registered per-country length, MOD-97-10 check digitsISO 13616 / ISO 7064
Bic8 or 11 chars, letters in the institution and country codesISO 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_i64serde
Serde adapter module for encoding MarktpartnerId as a JSON integer (i64).
schemaschemars or utoipa
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.
BilanzierungsgebietId
Bilanzierungsgebiet-ID: a 16-character EIC code with object type 'Y' (Area).
BilanzkreisId
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.
LokationsbuendelObjektcode
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.
MarktpartnerId
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).
ObisCode
OBIS identifier (IEC 62056-61 / BDEW): compact reference for metering values.
ObisComponents
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).
TranchennummerId
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.
MaloVergabestelle
Issuing office (Vergabestelle) encoded in the first digit of a MaLo-ID.
MpIdAuthority
The authority that issued a MarktpartnerId, derived from its first two digits.
Zaehlpunktart
Which kind of point a Zaehlpunktbezeichnung names.

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+ACD reference 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_countserde
Returns the total number of identifier deserialization validation failures observed in this process (across all identifier types).