osdp/command/abort.rs
1//! `osdp_ABORT` (`0xA2`) — abort current operation. Empty body.
2//!
3//! # Spec: §6.24
4
5use crate::error::Error;
6use alloc::vec::Vec;
7
8/// `osdp_ABORT` body (empty).
9#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
10pub struct Abort;
11
12impl Abort {
13 /// Encode.
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: 0xA2,
23 reason: "ABORT has no payload",
24 });
25 }
26 Ok(Self)
27 }
28}