Skip to main content

detect_missing_packets

Function detect_missing_packets 

Source
pub fn detect_missing_packets(last: Option<u8>, current: u8) -> Vec<u8> โ“˜
Expand description

Detect missing packets between last and current in the 0โ€“127 ring.

Returns a list of the missing packet indices. Returns an empty list when last is None (first packet) or current is the expected successor.

ยงExample

assert!(detect_missing_packets(None, 5).is_empty());
assert!(detect_missing_packets(Some(5), 6).is_empty());
assert_eq!(detect_missing_packets(Some(5), 8), vec![6, 7]);
assert_eq!(detect_missing_packets(Some(126), 1), vec![127, 0]);