rubo4e 0.1.0

Rust implementation of the BO4E energy-market data standard
Documentation

rubo4e ⚡

A Rust implementation of the BO4E energy-market data standard — the canonical data model for the German energy industry.

⚠️ This is not an official BO4E implementation. The official reference implementation is BO4E-python. This crate aims for idiomatic Rust ergonomics, strong domain types, and ecosystem integration.

Crates.io License: MIT License: Apache 2.0 Rust 1.87+


✨ Features

  • 🏗️ Generated types from the official BO4E JSON Schema (v202501)
  • 🔒 Strong domain identifiers — MaloId, MeloId, EicCode, ObisCode, … with embedded validation
  • ✅ Three-layer validation — constructor checks, garde struct rules, cross-field business logic
  • 🔧 Typed builders — compile-time required-field enforcement via typed-builder
  • 🌍 German / English / Canonical JSON — BO4E wire format out of the box
  • 📐 JSON Schema via schemars, OpenAPI via utoipa, DB via sqlx
  • 🧪 Proptest strategies, golden corpus, and fuzz harnesses included

📦 Installation

Add to your Cargo.toml:

[dependencies]
rubo4e = "0.1"

Enable optional features as needed:

rubo4e = { version = "0.1", features = ["json", "versioned", "validate", "builder"] }

🚀 Quick Start

use rubo4e::prelude::*;
use rubo4e::v202501::{Vertrag, Sparte};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Builder with compile-time required-field enforcement (requires `builder` feature)
    let vertrag = Vertrag::builder()
        .sparte(Sparte::Strom)
        .beschreibung("Jahresvertrag Strom".to_string())
        .vertragsnummer("VN-2025-001".to_string())
        .build();

    // Cross-field struct validation (requires `validate` feature)
    use garde::Validate as _;
    vertrag.validate()?;

    // German camelCase JSON — BO4E wire format (requires `json` feature)
    let json = vertrag.to_json_german()?;
    println!("{json}");

    Ok(())
}

🎛️ Feature Gates

Feature Default Description
serde ✓ Serde derives + extension-data map
json serde_json helpers (to_json_german(), …)
simd-json SIMD-accelerated JSON parsing backend
time time crate for timestamps
decimal rust_decimal::Decimal for amounts and prices
builder typed-builder derives
validate garde validation
schemars JSON Schema generation
sqlx sqlx type integrations (PostgreSQL)
utoipa utoipa OpenAPI integration
strum Enum iteration and string conversion
versioned Versioned schema modules (v202501)
tracing Structured diagnostics via the tracing crate
metrics Counter export hooks (metrics ecosystem)

🗂️ Schema Versions

Module Status
v202501 ✅ Latest stable

Use the versioned module to pin a stable schema:

use rubo4e::v202501::Marktlokation;

🏷️ Identifiers

All domain identifiers validate their format on construction:

Type Format / Rule
MaloId 11 digits, BDEW alternating-weight checksum
MeloId 33-character DE-prefixed alphanumeric string
NeloId 11-character alphanumeric string
EicCode 16-character EIC with checksum (A, T, V, W, X, Y, Z)
ObisCode OBIS identifier (e.g. 1-1:1.8.0)
MarktpartnerId 13-digit numeric BDEW identifier
SrId Non-empty string (Steuerobjekt-Referenz)
TrId Non-empty string (Tranche-Referenz)

📚 Documentation


🔗 Related Projects

Project Language Notes
BO4E-python Python Official reference implementation
BO4E-Schemas JSON Schema Canonical schema source
go-bo4e Go Most mature non-Python implementation
bo4e-rust Rust Hochfrequenz's Rust implementation

📜 License

Dual-licensed under MIT or Apache 2.0 — your choice.

The BO4E standard itself is maintained by the Interessengemeinschaft Geschäftsobjekte Energiewirtschaft e. V..