Skip to main content

Crate rubo4e

Crate rubo4e 

Source
Expand description

§rubo4e

Rust implementation of the BO4E energy-market data standard.

§Feature gates

FeatureDefaultDescription
identifiers✓Identifier types (MaloId, EicCode, ObisCode, …) + serde
serde✓Serde derives + extension-data map
jsonserde_json helpers (to_json_*, from_json_*)
timetime crate for timestamps; also utoipa/time
decimalrust_decimal::Decimal for amounts/prices (see note below); also schemars/rust_decimal1 and utoipa/decimal
buildertyped-builder derives with setter(into) — accepts both T and Option<T>
validategarde validation
schemarsJSON Schema generation
sqlxsqlx type integrations
utoipautoipa OpenAPI integrations
strumEnum iteration and string conversion
versionedExpose the versioned schema module (v202607)
tracingStructured diagnostics via the tracing crate
metricsOptional export hooks via the metrics crate

§Where to start

You want toLook at
Read or write a BO4E payloadcurrent, json::Bo4eJsonExt
Reject a payload that carries an out-of-schema valueBo4eStrict, Bo4eEnum
Check that a document you produced uses only fields BO4E definesjson::Bo4eExtensions
Check a market identifieridentifiers
Read a Lokationsbündelstruktur, or check onelokationsbuendel
Carry something BO4E does not modelzusatz_attribut
Check a document against BO4E’s own rulesvalidation
Work with a Lastgang, Zeitreihe or Zaehlwerktimeseries
Convert between units, or turn power into energyunits

§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:

FeatureWithoutWith
decimalOption<String>Option<rust_decimal::Decimal>
timeOption<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§

convenienceversioned
Hand-written convenience methods on generated BO4E types.
currentversioned
The latest stable BO4E schema series this crate ships — currently v202607.
decimal_serdeserde
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_durationtime
ISO 8601 duration parsing for BO4E’s dauer fields.
jsonjson
JSON serialization helpers: json::Bo4eJsonExt with to_json_german(), to_json_snake_case(), and to_json_canonical(). JSON serialization helpers for BO4E types.
lokationsbuendel
The Lokationsbündelstruktur: what sits behind one Netzanschluss, and where.
offset_timetime
Time-of-day parsing for BO4E’s format: "time" fields.
prelude
Re-exports the most commonly used traits and every identifier type.
schema_helpersschemars
Schema helper functions used by generated schemars attributes.
strictversioned
Strict-decoding support: reject out-of-schema (Unknown) enum values anywhere in a deserialized payload. See Bo4eStrict and strict::StrictError. Strict-decoding support for BO4E payloads.
time_serdeserde and time
Serde modules for time::Date fields in generated structs.
timeseriestime and versioned
Placing a BO4E time series on a timeline, and reading what it means.
unitsversioned
Physical dimensions and unit arithmetic for BO4E’s Mengeneinheit.
v202607versioned
BO4E schema v202607 types.
validationvalidate
Cross-field business-rule validators for BO4E types (requires validate + versioned). Also exports Validated<T> which only requires validate. Cross-field business-rule validators for BO4E types, plus the Validated wrapper.
zusatz_attributversioned
Namespaced ZusatzAttributs: the supported way to carry what BO4E does not model.

Structs§

LimitedExtensionMapjson
Always-available re-export of json::extension::LimitedExtensionMap.

Traits§

Bo4eComponentversioned
Marks a generated component (COM) — the BO4E types that appear nested inside a Geschäftsobjekt rather than on their own.
Bo4eEnumversioned
Uniform introspection & strict-parsing surface implemented by every generated BO4E enum (Zaehlertyp, Marktrolle, BdewArtikelnummer, …).
Bo4eObjectversioned
Marks a generated Geschäftsobjekt — the BO4E types that stand on their own as a message payload.
Bo4eStrictversioned
Recursive strict-decode check: find every out-of-schema (Unknown) enum value anywhere inside a deserialized BO4E value.
Bo4eTypedversioned
The _typ discriminant, as constants — implemented by every generated BO and COM.