edifact-mapper
Bidirectional EDIFACT to BO4E conversion for the German energy market.
Installation
Data Setup
The mapping engine requires pre-built data bundles. Download them with the CLI:
# Fetch a specific format version
# Or all available versions
# List locally available bundles
Data is stored in ~/.edifact/data/ by default. Override with $EDIFACT_DATA_DIR.
Usage
High-Level API
use ;
let mapper = from_data_dir.unwrap;
// Get a conversion service for tree assembly
let service = mapper.conversion_service.unwrap;
// Get a mapping engine for a specific PID
let engine = mapper.engine.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 ;
let mapper = from_data_dir.unwrap;
let service = mapper.conversion_service.unwrap;
let tree = service.convert_to_assembled_tree.unwrap;
Standalone Parser
If you only need EDIFACT parsing without BO4E mapping:
use 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