Skip to main content

Crate bo4e

Crate bo4e 

Source
Expand description

§BO4E - Business Objects for Energy

Rust implementation of the BO4E standard for data exchange in the German energy industry.

§Quick Start

use bo4e::prelude::*;

// Create a meter
let meter = Meter {
    meter_number: Some("1EMH0012345678".to_string()),
    division: Some(Division::Electricity),
    meter_type: Some(MeterType::ModernMeasuringDevice),
    ..Default::default()
};

// Serialize to German JSON (BO4E standard)
let json = to_json_german(&meter).unwrap();
println!("{}", json);

// Deserialize
let mut bytes = json.into_bytes();
let parsed: Meter = from_json(&mut bytes).unwrap();
assert_eq!(parsed.meter_number, Some("1EMH0012345678".to_string()));

§Crate Structure

  • bo - Business Objects (Meter, MarketLocation, Contract, etc.)
  • com - Components (Address, Price, MeterReading, etc.)
  • enums - Enumerations (Division, MeterType, ContractStatus, etc.)

§Serialization

BO4E uses German field names in JSON by default to maintain compatibility with the standard. Use to_json_english for English field names.

use bo4e::prelude::*;

let meter = Meter::default();

// German (standard)
let german = to_json_german(&meter).unwrap();

// English
let english = to_json_english(&meter).unwrap();

§Performance

This crate uses simd-json for SIMD-accelerated JSON parsing. For best performance, use from_json with a mutable byte slice.

Modules§

bo
Business Objects (BOs) - top-level entities in BO4E.
com
Components (COMs) - composite types used within Business Objects.
enums
Enumerations for BO4E type-safe values.
prelude
Prelude for convenient imports.
traits
Core traits and types for BO4E objects.

Structs§

Bo4eMeta
Metadata common to all BO4E objects.
SerializeConfig
Configuration for JSON serialization.

Enums§

Error
Error type for serialization operations.
JsonLanguage
Controls JSON field naming language.

Traits§

Bo4eObject
Trait implemented by all BO4E types.

Functions§

from_json
Deserialize a BO4E object from JSON.
to_json_english
Serialize a BO4E object to JSON with English field names.
to_json_german
Serialize a BO4E object to JSON with German field names.