Skip to main content

Crate rubo4e

Crate rubo4e 

Source
Expand description

§bo4e

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_*)
simd-jsonSIMD parser backend for from_json_* (workload-dependent)
timetime crate for timestamps
decimalrust_decimal::Decimal for amounts/prices (see note below)
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

§Identifiers without schema overhead

All identifier types (MaloId, MeloId, NeloId, EicCode, ObisCode, MarktpartnerId, SrId, TrId) always provide Display, FromStr, TryFrom<&str>, TryFrom<String>, and AsRef<str> without any feature flags — the minimum needed for EDIFACT wire-format encoding/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 serde feature is included in default = ["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:

FeatureWithout featureWith featureAffected fields
decimalOption<String>Option<rust_decimal::Decimal>wert, preis, amounts, quantities
timeOption<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/time and use the strong types, or
  • Access fields through JSON round-trip (to_json_german / from_json_german) which is feature-independent.

The string fallback preserves the ISO-8601 / decimal string value from JSON so data is never lost when these features are absent.

§Why generated structs do not implement Eq

Generated BO and COM structs derive PartialEq but not Eq. The _additional extension-data field (present when the json feature is active) has type LimitedExtensionMap whose inner map contains serde_json::Value. serde_json::Value does not implement Eq because it wraps f64 (JSON numbers), and f64 is not Eq (NaN ≠ NaN). This is intentional and correct behaviour.

For content-addressed equality comparisons, use to_json_canonical() (from Bo4eJsonExt in the json module) which produces a deterministic byte string that can be compared with ==.

Re-exports§

pub use v202607 as current;versioned

Modules§

convenienceversioned
Hand-written convenience methods on generated BO4E types.
error
Error types returned by identifier construction.
identifiers
Domain identifier newtypes for BO4E energy-market entities.
jsonjson
JSON serialization helpers: json::Bo4eJsonExt with to_json_german(), to_json_snake_case(), and to_json_canonical(). JSON serialization helpers for BO4E types.
prelude
Re-exports the most commonly used types.
schema_helpersschemars
Schema helper functions used by generated schemars attributes.
time_serdetime
Serde modules for time::Date fields in generated structs.
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.

Structs§

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

Traits§

Bo4eObjectversioned
Marker trait implemented by every generated BO4E business object (Geschäftsobjekt).