use crate::binxml::Event;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RecordIdGap {
pub missing_start: u64,
pub missing_end: u64,
pub prev: u64,
pub next: u64,
}
pub fn detect_gaps(records: &[Event]) -> Vec<RecordIdGap> {
let mut ids: Vec<u64> = records
.iter()
.map(|e| e.record_id)
.filter(|&r| r != 0)
.collect();
ids.sort_unstable();
ids.dedup();
let mut out = Vec::new();
for w in ids.windows(2) {
let (a, b) = (w[0], w[1]);
if b > a + 1 {
out.push(RecordIdGap {
missing_start: a + 1,
missing_end: b - 1,
prev: a,
next: b,
});
}
}
out
}