osdp/command/
acu_rx_size.rs1use crate::error::Error;
8use alloc::vec::Vec;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
12pub struct AcuRxSize {
13 pub max_size: u16,
15}
16
17impl AcuRxSize {
18 pub fn encode(&self) -> Result<Vec<u8>, Error> {
20 Ok(self.max_size.to_le_bytes().to_vec())
21 }
22
23 pub fn decode(data: &[u8]) -> Result<Self, Error> {
25 if data.len() != 2 {
26 return Err(Error::MalformedPayload {
27 code: 0x7B,
28 reason: "ACURXSIZE requires 2 bytes",
29 });
30 }
31 Ok(Self {
32 max_size: u16::from_le_bytes([data[0], data[1]]),
33 })
34 }
35}