osdp/command/
local_status.rs1use crate::error::Error;
11use alloc::vec::Vec;
12
13macro_rules! empty_status {
14 ($Ty:ident, $code:expr, $name:literal) => {
15 #[doc = concat!("`", $name, "` body (empty).")]
16 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
17 pub struct $Ty;
18
19 impl $Ty {
20 pub fn encode(&self) -> Result<Vec<u8>, Error> {
22 Ok(Vec::new())
23 }
24
25 pub fn decode(data: &[u8]) -> Result<Self, Error> {
27 if !data.is_empty() {
28 return Err(Error::MalformedPayload {
29 code: $code,
30 reason: concat!($name, " has no payload"),
31 });
32 }
33 Ok(Self)
34 }
35 }
36 };
37}
38
39empty_status!(LocalStatus, 0x64, "osdp_LSTAT");
40empty_status!(InputStatus, 0x65, "osdp_ISTAT");
41empty_status!(OutputStatus, 0x66, "osdp_OSTAT");
42empty_status!(ReaderStatus, 0x67, "osdp_RSTAT");