Expand description
§rubo4e
Rust implementation of the BO4E energy-market data standard.
§Feature gates
| Feature | Default | Description |
|---|---|---|
identifiers | ✓ | Identifier types (MaloId, EicCode, ObisCode, …) + serde |
serde | ✓ | Serde derives + extension-data map |
json | serde_json helpers (to_json_*, from_json_*) | |
time | time crate for timestamps; also utoipa/time | |
decimal | rust_decimal::Decimal for amounts/prices (see note below); also schemars/rust_decimal1 and utoipa/decimal | |
builder | typed-builder derives with setter(into) — accepts both T and Option<T> | |
validate | garde validation | |
schemars | JSON Schema generation | |
sqlx | sqlx type integrations | |
utoipa | utoipa OpenAPI integrations | |
strum | Enum iteration and string conversion | |
versioned | Expose the versioned schema module (v202607) | |
tracing | Structured diagnostics via the tracing crate | |
metrics | Optional export hooks via the metrics crate |
§Where to start
| You want to | Look at |
|---|---|
| Read or write a BO4E payload | current, json::Bo4eJsonExt |
| Reject a payload that carries an out-of-schema value | Bo4eStrict, Bo4eEnum |
| Check that a document you produced uses only fields BO4E defines | json::Bo4eExtensions |
| Check a market identifier | identifiers |
| Read a Lokationsbündelstruktur, or check one | lokationsbuendel |
| Carry something BO4E does not model | zusatz_attribut |
| Check a document against BO4E’s own rules | validation |
Work with a Lastgang, Zeitreihe or Zaehlwerk | timeseries |
| Convert between units, or turn power into energy | units |
§Feature-conditional field types (decimal and time)
Enabling decimal or time changes the Rust type of certain fields, so
code written against one configuration may not compile under the other:
| Feature | Without | With |
|---|---|---|
decimal | Option<String> | Option<rust_decimal::Decimal> |
time | Option<String> | Option<time::OffsetDateTime> / Option<time::Date> |
The string fallback keeps the value’s lexical form, so nothing is lost.
Decimal fields read a JSON number as well as a JSON string, because BO4E
producers use both — but only the string spelling is exact. See
decimal_serde, which also counts every number read.
§Eq and Hash on generated structs
Generated structs always derive PartialEq, and additionally Eq + Hash
when json is off — so a BO can key a HashMap. serde_json::Value
blocks both, and it appears twice with json on: in LimitedExtensionMap and
as ZusatzAttribut::wert. Generated enums are always Eq + Ord + Hash.
For content-addressed equality under any feature set, compare
to_json_canonical() from json::Bo4eJsonExt.
§Identifiers without the schema
default = ["identifiers"] gives the identifier newtypes and serde, with no
versioned-schema overhead. Every identifier provides Display, FromStr,
TryFrom, AsRef<str>, Borrow<str> and Deref<Target = str> unfeatured —
the minimum an EDIFACT encoder needs.
rubo4e = { version = "...", default-features = false, features = ["identifiers"] }Modules§
- convenience
versioned - Hand-written convenience methods on generated BO4E types.
- current
versioned - The latest stable BO4E schema series this crate ships — currently
v202607. - decimal_
serde serde - Decimal deserialization, and what BO4E’s two spellings of a number cost.
- error
- Error types returned by identifier construction.
- identifiers
- Domain identifier newtypes for BO4E energy-market entities.
- iso8601_
duration time - ISO 8601 duration parsing for BO4E’s
dauerfields. - json
json - JSON serialization helpers:
json::Bo4eJsonExtwithto_json_german(),to_json_snake_case(), andto_json_canonical(). JSON serialization helpers for BO4E types. - lokationsbuendel
- The Lokationsbündelstruktur: what sits behind one Netzanschluss, and where.
- offset_
time time - Time-of-day parsing for BO4E’s
format: "time"fields. - prelude
- Re-exports the most commonly used traits and every identifier type.
- schema_
helpers schemars - Schema helper functions used by generated schemars attributes.
- strict
versioned - Strict-decoding support: reject out-of-schema (
Unknown) enum values anywhere in a deserialized payload. SeeBo4eStrictandstrict::StrictError. Strict-decoding support for BO4E payloads. - time_
serde serdeandtime - Serde modules for
time::Datefields in generated structs. - timeseries
timeandversioned - Placing a BO4E time series on a timeline, and reading what it means.
- units
versioned - Physical dimensions and unit arithmetic for BO4E’s
Mengeneinheit. - v202607
versioned - BO4E schema v202607 types.
- validation
validate - Cross-field business-rule validators for BO4E types (requires
validate+versioned). Also exportsValidated<T>which only requiresvalidate. Cross-field business-rule validators for BO4E types, plus theValidatedwrapper. - zusatz_
attribut versioned - Namespaced
ZusatzAttributs: the supported way to carry what BO4E does not model.
Structs§
- Limited
Extension Map json - Always-available re-export of
json::extension::LimitedExtensionMap.
Traits§
- Bo4e
Component versioned - Marks a generated component (COM) — the BO4E types that appear nested inside a Geschäftsobjekt rather than on their own.
- Bo4e
Enum versioned - Uniform introspection & strict-parsing surface implemented by every
generated BO4E enum (
Zaehlertyp,Marktrolle,BdewArtikelnummer, …). - Bo4e
Object versioned - Marks a generated Geschäftsobjekt — the BO4E types that stand on their own as a message payload.
- Bo4e
Strict versioned - Recursive strict-decode check: find every out-of-schema (
Unknown) enum value anywhere inside a deserialized BO4E value. - Bo4e
Typed versioned - The
_typdiscriminant, as constants — implemented by every generated BO and COM.