Skip to main content

dump_structure/
dump_structure.rs

1//! Validation helper: dump SEGB record structure (state, timestamp, payload
2//! length) — NOT payload content. Run against a real Biome SEGB file (e.g.
3//! `App.MenuItem`) to reconcile `segb-core`'s container parse with the
4//! `ccl-segb` reference.
5//!
6//! Usage: `cargo run -p segb-core --example dump_structure -- <segb-file>`
7#![allow(clippy::unwrap_used, clippy::expect_used)]
8
9fn main() {
10    let path = std::env::args()
11        .nth(1)
12        .expect("usage: dump_structure <segb-file>");
13    let data = std::fs::read(&path).expect("read file");
14    let mut cur = std::io::Cursor::new(data);
15    let records = segb::read_segb(&mut cur).expect("parse SEGB");
16    println!("records: {}", records.len());
17    for (i, r) in records.iter().enumerate() {
18        // `crc_ok` is emitted so the differential harness can reconcile our
19        // CRC verdict against ccl-segb's `crc_passed` (Written records only).
20        println!(
21            "  [{i}] state={:?} ts_unix={:?} crc_ok={} payload_len={}",
22            r.state(),
23            r.timestamp_unix(),
24            r.crc_ok(),
25            r.payload().len()
26        );
27    }
28}