1use crate::error::Error;
8use alloc::vec::Vec;
9
10#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
12pub struct Id {
13 pub reserved: u8,
15}
16
17impl Id {
18 pub const fn standard() -> Self {
20 Self { reserved: 0 }
21 }
22
23 pub fn encode(&self) -> Result<Vec<u8>, Error> {
25 Ok(alloc::vec![self.reserved])
26 }
27
28 pub fn decode(data: &[u8]) -> Result<Self, Error> {
30 if data.len() != 1 {
31 return Err(Error::MalformedPayload {
32 code: 0x61,
33 reason: "ID requires 1-byte reserved field",
34 });
35 }
36 Ok(Self { reserved: data[0] })
37 }
38}