Skip to main content

message_windows_bytes

Function message_windows_bytes 

Source
pub fn message_windows_bytes(input: &[u8]) -> MessageWindowsSliceIter<'_> 
Expand description

Stream-parse EDIFACT bytes into an iterator of per-message windows.

Each window is a Vec<Segment<'_>> spanning one UNH..UNT pair, with segments borrowing from inputzero heap allocations per segment. Envelope segments (UNB, UNZ, …) are skipped automatically.

§Example

use edifact_rs::message_windows_bytes;
let input = b"UNB+UNOA:1+SENDER+RECEIVER+200101:0900+1'\
              UNH+1+ORDERS:D:96A:UN'\
              BGM+220+PO-001+9'\
              UNT+3+1'\
              UNZ+1+1'";

let windows: Vec<_> = message_windows_bytes(input)
    .collect::<Result<_, _>>()
    .unwrap();
assert_eq!(windows.len(), 1);
assert_eq!(windows[0][0].tag, "UNH");
assert_eq!(windows[0].last().unwrap().tag, "UNT");