Skip to main content

osdp/reply/
ack.rs

1//! `osdp_ACK` (`0x40`). Empty body.
2//!
3//! # Spec: ยง7.1
4
5use crate::error::Error;
6use alloc::vec::Vec;
7
8/// `osdp_ACK` body.
9#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
10pub struct Ack;
11
12impl Ack {
13    /// Encode (always empty).
14    pub fn encode(&self) -> Result<Vec<u8>, Error> {
15        Ok(Vec::new())
16    }
17
18    /// Decode.
19    pub fn decode(data: &[u8]) -> Result<Self, Error> {
20        if !data.is_empty() {
21            return Err(Error::MalformedPayload {
22                code: 0x40,
23                reason: "ACK has no payload",
24            });
25        }
26        Ok(Self)
27    }
28}