From 04ab5e2c4ca890bb310cbdc835123ca1cc36d291 Mon Sep 17 00:00:00 2001 From: Tobias Maier Date: Sun, 7 Dec 2025 17:13:35 +0100 Subject: [PATCH] added display --- src/enums.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/enums.rs b/src/enums.rs index 0ed8fa7..6c7f8f4 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -1,3 +1,5 @@ +use core::fmt; + use num_enum::{IntoPrimitive, TryFromPrimitive}; /// Message Identifier used in the communication protocol. This is specified by Viessmann @@ -11,6 +13,17 @@ pub enum MessageIdentifier { CommError = 0x03, } +impl fmt::Display for MessageIdentifier { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Request => write!(f, "Request"), + Self::Response => write!(f, "Response"), + Self::Unacked => write!(f, "Unacked"), + Self::CommError => write!(f, "CommError"), + } + } +} + /// Function Code used in the communication protocol. /// /// This is specified by Viessmann and Read and Write are usually used for simpler values, @@ -23,6 +36,16 @@ pub enum FunctionCode { RemoteProcedureCall = 0x07, } +impl std::fmt::Display for FunctionCode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::VirtualREAD => write!(f, "VirtualREAD"), + Self::VirtualWRITE => write!(f, "VirtualWRITE"), + Self::RemoteProcedureCall => write!(f, "RemoteProcedureCall"), + } + } +} + /// Response code used in the communication protocol. This is specified by Viessmann #[repr(u8)] #[derive(Debug, TryFromPrimitive)]