use crate::prelude::*;
#[derive(Copy, Clone, Debug)]
pub struct Lost {
pub id: u64,
pub lost: u64,
}
impl<'p> Parse<'p> for Lost {
fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
where
E: Endian,
B: ParseBuf<'p>,
{
Ok(Self {
id: p.parse()?,
lost: p.parse()?,
})
}
}
#[cfg(test)]
mod tests {
use crate::endian::Little;
use super::*;
#[test]
fn test_parse() {
#[rustfmt::skip]
let bytes: &[u8] = &[
0x10, 0x00, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xAF, 0x00, 0x00, 0x00, 0x7B, 0x00, 0x00
];
let mut parser: Parser<_, Little> = Parser::new(bytes, ParseConfig::default());
let lost: Lost = parser.parse().unwrap();
assert_eq!(lost.id, 0x990010);
assert_eq!(lost.lost, 0x7B000000AF00);
}
}