Skip to main content

Crate edifact_mapper

Crate edifact_mapper 

Source
Expand description

§edifact-mapper

EDIFACT to BO4E bidirectional conversion for the German energy market.

This crate provides a high-level Mapper API that loads precompiled DataBundle files and exposes ConversionService and MappingEngine instances for specific format versions, message variants, and PIDs.

§Quick Start — Outbound (BO4E → EDIFACT)

use edifact_mapper::{DataDir, Mapper};

let mapper = Mapper::from_data_dir(DataDir::auto())?;

let edifact = mapper.to_edifact(
    &msg_stammdaten, &tx_stammdaten,
    "FV2504", "UTILMD_Strom", "55001",
)?;

§Quick Start — Inbound (EDIFACT → BO4E)

For inbound messages where the PID is not known upfront, use Mapper::detect_pid to extract it from the EDIFACT content:

use edifact_mapper::{DataDir, Mapper};

let mapper = Mapper::from_data_dir(DataDir::auto())?;

// Step 1: Detect PID from raw EDIFACT (reads RFF+Z13 or BGM+STS)
let pid = mapper.detect_pid(edifact_str)?;

// Step 2: Convert to typed BO4E interchange
let interchange: DynamicInterchange =
    mapper.from_edifact(edifact_str, "FV2504", "UTILMD_Strom", &pid)?;

§Mid-level Access

For advanced use cases, key types from internal crates are re-exported:

Re-exports§

pub use data_dir::DataDir;
pub use error::MapperError;
pub use mapper::Bo4eResult;
pub use mapper::EdifactParty;
pub use mapper::InterchangeEnvelope;
pub use mapper::InterchangeMessage;
pub use mapper::Mapper;
pub use mapper::MessageMetadata;
pub use edifact_parser;

Modules§

data_dir
Data directory configuration for locating DataBundle files on disk.
error
Error types for the edifact-mapper facade crate.
evaluator_factory
Factory for creating condition evaluators by variant name and format version.
mapper
High-level Mapper API for EDIFACT-to-BO4E conversion.

Structs§

AssembledTree
A generic assembled tree node (before PID-specific typing).
ConversionService
High-level service that holds a parsed MIG schema and provides convenient methods for EDIFACT conversion.
DataBundle
Bundled data for a single format version (e.g., FV2504).
Disassembler
MIG-guided disassembler — walks the MIG tree to emit segments in correct order.
EdifactDelimiters
EDIFACT delimiter characters.
MappedMessage
Intermediate result from mapping a single message’s assembled tree.
MappedTransaktion
Internal engine type for a forward-mapped transaction.
MappingEngine
The mapping engine holds all loaded mapping definitions and provides methods for bidirectional conversion.
ValidationReport
A collection of validation errors for a PID.
VariantCache
Precompiled cache for a single format-version/variant (e.g., FV2504/UTILMD_Strom).

Enums§

PidValidationError
A single PID validation error.

Functions§

filter_mig_for_pid
Filter a MIG schema to only include segments and groups whose segment number fields appear in the given AHB number set.
render_edifact
Render a list of disassembled segments into an EDIFACT string.
validate_with_conditions
Validate a BO4E JSON value against PID requirements with AHB condition awareness.