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 |
§Identifiers without schema overhead
Every identifier type always provides Display, FromStr,
TryFrom<&str>, TryFrom<String>, Into<String>, AsRef<str>,
Borrow<str>, and Deref<Target = str> without any feature flag — the
minimum needed for EDIFACT wire-format encoding and decoding.
To use only identifier types without pulling in the versioned BO4E schema:
rubo4e = { version = "...", default-features = false, features = ["identifiers"] }This gives serde support on all identifiers with zero versioned-schema overhead.
§serde is enabled by default
The default feature set is default = ["identifiers"], and identifiers
enables serde. Targets that only need the type definitions for in-memory
processing can opt out:
rubo4e = { version = "...", default-features = false, features = ["versioned"] }§Feature-conditional field types (decimal and time)
Enabling decimal or time changes the Rust type of certain struct fields:
| Feature | Without feature | With feature | Affected fields |
|---|---|---|---|
decimal | Option<String> | Option<rust_decimal::Decimal> | wert, preis, amounts, quantities |
time | Option<String> | Option<time::OffsetDateTime> or Option<time::Date> | beginn/ende fields → OffsetDateTime; *datum fields → Date |
This means code that compiles under one feature configuration may not compile under the other. For code that must be feature-agnostic, either:
- Always enable
decimal/timeand use the strong types, or - Access fields through JSON round-trip (
to_json_german/from_json_german) which is feature-independent.
The string fallback keeps the value’s lexical form, so nothing is lost when these features are absent.
Decimal fields read a JSON number as well as a JSON string, because BO4E
producers use both — but only the string spelling is exact. A number has
already passed through f64 before this crate sees it, losing its scale
(119.00 → 119) and any precision past ~15 significant digits.
decimal_serde documents the whole picture and counts every such read.
§Eq and Hash on generated structs
Generated BO and COM structs always derive PartialEq. They additionally
derive Eq and Hash when the json feature is off, which is what lets
them key a HashMap or a HashSet.
One type blocks both: serde_json::Value, which appears in a generated
struct twice when json is on — inside LimitedExtensionMap (the
_additional field) and as ZusatzAttribut::wert. Value is neither Eq
nor Hash, because it wraps f64 and NaN != NaN. With json off both
degrade to a ZST stub and a String, and the whole tree becomes Eq + Hash.
Generated enums are always Eq + Ord + Hash, whatever the features.
For content-addressed equality across every feature set, compare
to_json_canonical() (from Bo4eJsonExt in the json module), which
produces a deterministic byte string.
Modules§
- convenience
versioned - Hand-written convenience methods on generated BO4E types.
- current
versioned - Current stable BO4E schema version — always resolves to the latest stable schema
(
v202607in this release). - 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. - offset_
time time - Time-of-day parsing for BO4E’s
format: "time"fields. - prelude
- Re-exports the most commonly used types.
- 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. - 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.
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.