edifact-mapper 0.13.0

EDIFACT to BO4E bidirectional conversion for the German energy market
Documentation

edifact-mapper

Bidirectional EDIFACT to BO4E conversion for the German energy market.

Installation

cargo add edifact-mapper
cargo install edifact-data

Data Setup

The mapping engine requires pre-built data bundles. Download them with the CLI:

# Fetch a specific format version
edifact-data fetch FV2504

# Or all available versions
edifact-data fetch --all

# List locally available bundles
edifact-data list

Data is stored in ~/.edifact/data/ by default. Override with $EDIFACT_DATA_DIR.

Usage

High-Level API

use edifact_mapper::{DataDir, Mapper};

let mapper = Mapper::from_data_dir(DataDir::auto()).unwrap();

// Get a conversion service for tree assembly
let service = mapper.conversion_service("FV2504", "UTILMD_Strom").unwrap();

// Get a mapping engine for a specific PID
let engine = mapper.engine("FV2504", "UTILMD_Strom", "55001").unwrap();

Code fields: names or raw codes

Where the guide gives a code list, from_edifact writes a code as its name (NAD+Z65 → "partnerrolle": "kundeDesLf") — the canonical form. to_edifact accepts either: a name is written back as its code, and any other value (the raw code "Z65" included) is written as it is, so both render the same message. Names are release-specific, codes are not: a release may rename a code, and a name the current table no longer has is written as it is onto the wire — store or replay raw codes across releases. To read them, pass FromEdifactOptions { codes: CodeForm::Raw } to Mapper::from_edifact_with: "partnerrolle": "Z65", still enriched with its meaning. An element the guide gives no code list for — e.g. STS+E01 D_9013, whose codes come from the decision-tree list D_1131 names — is written as its raw value in both directions.

Mid-Level Access

use edifact_mapper::{AssembledTree, ConversionService, MappingEngine, Mapper, DataDir};

let mapper = Mapper::from_data_dir(DataDir::auto()).unwrap();
let service = mapper.conversion_service("FV2504", "UTILMD_Strom").unwrap();
let tree = service.convert_to_assembled_tree(&edifact_input).unwrap();

Standalone Parser

If you only need EDIFACT parsing without BO4E mapping:

cargo add edifact-parser
use edifact_parser::EdifactStreamParser;

Environment Variables

Variable Default Description
EDIFACT_DATA_DIR ~/.edifact/data/ Data bundle directory
GITHUB_TOKEN — GitHub token for private repo access (or use --token)

Supported Message Types

UTILMD (Strom/Gas), MSCONS, ORDERS, ORDRSP, REMADV, COMDIS, ORDCHG, PRICAT, IFTSTA, UTILTS, INVOIC, INSRPT, PARTIN, APERAK, CONTRL

Format Versions

FV2504, FV2510, FV2604

License

MIT