perf_event_data/records/
lost.rs1use crate::prelude::*;
2
3#[derive(Copy, Clone, Debug)]
8pub struct Lost {
9 pub id: u64,
11
12 pub lost: u64,
14}
15
16impl<'p> Parse<'p> for Lost {
17 fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
18 where
19 E: Endian,
20 B: ParseBuf<'p>,
21 {
22 Ok(Self {
23 id: p.parse()?,
24 lost: p.parse()?,
25 })
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use crate::endian::Little;
32
33 use super::*;
34
35 #[test]
36 fn test_parse() {
37 #[rustfmt::skip]
38 let bytes: &[u8] = &[
39 0x10, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0xAF, 0x00, 0x00, 0x00, 0x7B, 0x00, 0x00
41 ];
42
43 let mut parser: Parser<_, Little> = Parser::new(bytes, ParseConfig::default());
44 let lost: Lost = parser.parse().unwrap();
45
46 assert_eq!(lost.id, 0x990010);
47 assert_eq!(lost.lost, 0x7B000000AF00);
48 }
49}