1use crate::error::Error;
6use crate::payload_util::require_exact_len;
7use alloc::vec::Vec;
8
9#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
11pub struct Busy;
12
13impl Busy {
14 pub fn encode(&self) -> Result<Vec<u8>, Error> {
16 Ok(Vec::new())
17 }
18
19 pub fn decode(data: &[u8]) -> Result<Self, Error> {
21 require_exact_len(data, 0, 0x79)?;
22 Ok(Self)
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 #[test]
31 fn roundtrip_empty() {
32 assert!(Busy.encode().unwrap().is_empty());
33 assert_eq!(Busy::decode(&[]).unwrap(), Busy);
34 }
35
36 #[test]
37 fn decode_rejects_payload() {
38 assert!(matches!(
39 Busy::decode(&[0xFF]),
40 Err(Error::PayloadLength { code: 0x79, .. })
41 ));
42 }
43}