edifact_mapper/lib.rs
1//! # edifact-mapper
2//!
3//! EDIFACT to BO4E bidirectional conversion for the German energy market.
4//!
5//! This crate provides a high-level [`Mapper`] API that loads precompiled
6//! [`DataBundle`] files and exposes [`ConversionService`] and [`MappingEngine`]
7//! instances for specific format versions, message variants, and PIDs.
8//!
9//! # Quick Start
10//!
11//! ```ignore
12//! use edifact_mapper::{DataDir, Mapper};
13//!
14//! // Auto-detect data directory ($EDIFACT_DATA_DIR or ~/.edifact/data)
15//! let mapper = Mapper::from_data_dir(DataDir::auto())?;
16//!
17//! // Or explicit path with eager loading
18//! let mapper = Mapper::from_data_dir(
19//! DataDir::path("/opt/edifact/data").eager(&["FV2504"])
20//! )?;
21//!
22//! // Get a conversion service for EDIFACT parsing + MIG assembly
23//! let cs = mapper.conversion_service("FV2504", "UTILMD_Strom")?;
24//!
25//! // Get a mapping engine for a specific PID
26//! let engine = mapper.engine("FV2504", "UTILMD_Strom", "55001")?;
27//! ```
28//!
29//! # Mid-level Access
30//!
31//! For advanced use cases, key types from internal crates are re-exported:
32//!
33//! - [`ConversionService`] — tokenize EDIFACT input and assemble MIG trees
34//! - [`MappingEngine`] — convert between MIG trees and BO4E JSON
35//! - [`DataBundle`] / [`VariantCache`] — precompiled mapping data
36//! - [`edifact_parser`] — standalone EDIFACT parser (no BO4E dependency)
37
38mod conditional_validation;
39pub mod data_dir;
40pub mod error;
41pub mod evaluator_factory;
42pub mod mapper;
43mod tree_to_segments;
44
45pub use conditional_validation::validate_with_conditions;
46pub use data_dir::DataDir;
47pub use error::MapperError;
48pub use mapper::{Bo4eResult, Mapper};
49
50// Re-export key types from internal crates for mid-level access.
51pub use mig_assembly::assembler::AssembledTree;
52pub use mig_assembly::ConversionService;
53pub use mig_bo4e::engine::{DataBundle, VariantCache};
54pub use mig_bo4e::MappingEngine;
55
56// Re-export PID validation types.
57pub use mig_bo4e::pid_validation::{PidValidationError, ValidationReport};
58
59// Re-export the parser for standalone use.
60pub use edifact_parser;