pub struct ConversionService { /* private fields */ }Expand description
High-level service that holds a parsed MIG schema and provides convenient methods for EDIFACT conversion.
Implementations§
Source§impl ConversionService
impl ConversionService
Sourcepub fn new(
mig_path: &Path,
message_type: &str,
variant: Option<&str>,
format_version: &str,
) -> Result<ConversionService, AssemblyError>
pub fn new( mig_path: &Path, message_type: &str, variant: Option<&str>, format_version: &str, ) -> Result<ConversionService, AssemblyError>
Create a new ConversionService by loading a MIG XML file.
Sourcepub fn from_mig(mig: MigSchema) -> ConversionService
pub fn from_mig(mig: MigSchema) -> ConversionService
Create a ConversionService from an already-parsed MIG schema.
Sourcepub fn convert_to_tree(&self, input: &str) -> Result<Value, AssemblyError>
pub fn convert_to_tree(&self, input: &str) -> Result<Value, AssemblyError>
Convert EDIFACT input to an assembled tree, serialized as JSON.
Sourcepub fn convert_to_assembled_tree(
&self,
input: &str,
) -> Result<AssembledTree, AssemblyError>
pub fn convert_to_assembled_tree( &self, input: &str, ) -> Result<AssembledTree, AssemblyError>
Convert EDIFACT input to an AssembledTree (typed, not JSON).
Sourcepub fn convert_interchange_to_trees(
&self,
input: &str,
) -> Result<(InterchangeChunks, Vec<AssembledTree>), AssemblyError>
pub fn convert_interchange_to_trees( &self, input: &str, ) -> Result<(InterchangeChunks, Vec<AssembledTree>), AssemblyError>
Convert a complete interchange into per-message assembled trees.
Steps:
- Parse input to segments
- Split at UNH/UNT boundaries
- Assemble each message independently
Returns the InterchangeChunks (for envelope access) and a Vec<AssembledTree>
(one per message, in order).
Sourcepub fn convert_to_assembled_tree_with_config(
&self,
input: &str,
config: AssemblerConfig,
) -> Result<AssembledTree, AssemblyError>
pub fn convert_to_assembled_tree_with_config( &self, input: &str, config: AssemblerConfig, ) -> Result<AssembledTree, AssemblyError>
Convert EDIFACT input to an AssembledTree with custom assembler config.
Sourcepub fn convert_interchange_to_trees_with_config(
&self,
input: &str,
config: AssemblerConfig,
) -> Result<(InterchangeChunks, Vec<AssembledTree>), AssemblyError>
pub fn convert_interchange_to_trees_with_config( &self, input: &str, config: AssemblerConfig, ) -> Result<(InterchangeChunks, Vec<AssembledTree>), AssemblyError>
Convert a complete interchange into per-message assembled trees with custom config.
Sourcepub fn convert_interchange_to_trees_with_diagnostics(
&self,
input: &str,
config: AssemblerConfig,
) -> Result<(InterchangeChunks, Vec<AssembledTree>, Vec<StructureDiagnostic>), AssemblyError>
pub fn convert_interchange_to_trees_with_diagnostics( &self, input: &str, config: AssemblerConfig, ) -> Result<(InterchangeChunks, Vec<AssembledTree>, Vec<StructureDiagnostic>), AssemblyError>
convert_interchange_to_trees_with_config, plus the structure diagnostics
raised while assembling each message, in input order.
Callers that map the trees to BO4E should surface these: a
SkippedUnknownSegment means the message carried content the MIG has no
slot for, so the mapped result is missing it.