1use crate::error::Error;
9use alloc::vec::Vec;
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct LStatR {
14 pub tamper: u8,
16 pub power: u8,
18}
19
20impl LStatR {
21 pub fn encode(&self) -> Result<Vec<u8>, Error> {
23 Ok(alloc::vec![self.tamper, self.power])
24 }
25
26 pub fn decode(data: &[u8]) -> Result<Self, Error> {
28 if data.len() != 2 {
29 return Err(Error::MalformedPayload {
30 code: 0x48,
31 reason: "LSTATR requires 2 bytes",
32 });
33 }
34 Ok(Self {
35 tamper: data[0],
36 power: data[1],
37 })
38 }
39}