Expand description
§bo4e
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_*) | |
simd-json | SIMD parser backend for from_json_* (workload-dependent) | |
time | time crate for timestamps | |
decimal | rust_decimal::Decimal for amounts/prices (see note below) | |
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
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:
| 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 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§
- convenience
versioned - Hand-written convenience methods on generated BO4E types.
- error
- Error types returned by identifier construction.
- identifiers
- Domain identifier newtypes for BO4E energy-market entities.
- json
json - JSON serialization helpers:
json::Bo4eJsonExtwithto_json_german(),to_json_snake_case(), andto_json_canonical(). JSON serialization helpers for BO4E types. - prelude
- Re-exports the most commonly used types.
- schema_
helpers schemars - Schema helper functions used by generated schemars attributes.
- time_
serde time - 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
Object versioned - Marker trait implemented by every generated BO4E business object (Geschäftsobjekt).