pub struct Disassembler<'a> { /* private fields */ }Expand description
MIG-guided disassembler — walks the MIG tree to emit segments in correct order.
Implementations§
Source§impl<'a> Disassembler<'a>
impl<'a> Disassembler<'a>
pub fn new(mig: &'a MigSchema) -> Disassembler<'a>
Sourcepub fn disassemble(&self, tree: &AssembledTree) -> Vec<DisassembledSegment>
pub fn disassemble(&self, tree: &AssembledTree) -> Vec<DisassembledSegment>
Disassemble a tree into ordered segments following MIG sequence.
Emits segments in correct EDIFACT order:
- Pre-group top-level segments (e.g., UNB, UNH, BGM, DTM)
- Groups (recursively, in MIG order)
- Post-group top-level segments (e.g., UNT, UNZ)
Uses MIG-guided ordering: walks the MIG schema tree and looks up matching data in the assembled tree. This handles both assembler output (already in MIG order) and reverse-mapped trees (may be in arbitrary order).
This is lenient: a group instance lacking its entry segment is emitted
as-is. Use disassemble_checked for output
built from BO4E that is meant to be sent.
Sourcepub fn disassemble_checked(
&self,
tree: &AssembledTree,
) -> Result<Vec<DisassembledSegment>, AssemblyError>
pub fn disassemble_checked( &self, tree: &AssembledTree, ) -> Result<Vec<DisassembledSegment>, AssemblyError>
Like disassemble, but refuses a group instance
that has content without its MIG entry segment.
The entry segment opens a group repetition (CCI for SG10, SEQ for SG8,
NAD for SG12, …). Without it a receiver cannot assemble the group’s
other segments — our own assembler skips them, so their data is lost on
parse. The error names the first offending group; all of them are
available through missing_entry_segments.
Sourcepub fn missing_entry_segments(
&self,
tree: &AssembledTree,
) -> Vec<MissingEntrySegment>
pub fn missing_entry_segments( &self, tree: &AssembledTree, ) -> Vec<MissingEntrySegment>
Every group instance in tree that carries content but lacks its MIG
entry segment, in emission order.