added display

This commit is contained in:
2025-12-07 17:13:35 +01:00
parent a000c0854b
commit 04ab5e2c4c

View File

@@ -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)]