decode_exact_alloc/
decode_exact_alloc.rs1use meterbus_wired_datalink::{
13 CommunicationType, Frame,
14 decoder::exact::{DecodeError, decode},
15};
16
17fn main() -> Result<(), DecodeError> {
18 let frame = decode(&[0x10, 0x5b, 0x01, 0x5c, 0x16])?;
19
20 if let Frame::Short(short) = &frame {
21 assert_eq!(
22 short.control().communication_type(),
23 CommunicationType::ReqUd2
24 );
25 assert_eq!(short.address().value(), 1);
26 }
27
28 assert_eq!(frame.encode(), [0x10, 0x5b, 0x01, 0x5c, 0x16]);
29 Ok(())
30}