summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2024-05-26 13:19:51 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2024-05-26 13:19:51 +0530
commita264f3d40ffd89eb4e37c3d55f28219f7c444fda (patch)
tree0388d94012c299f9fd020a70746621d183a90ce3
parent16e7c1c80b4b8b2c48c5848b8b99d0339320fe15 (diff)
Make VRRPv2Error std::error::Error trait compliant.
-rw-r--r--src/vrrpv2.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vrrpv2.rs b/src/vrrpv2.rs
index f8445fb..ca8eaec 100644
--- a/src/vrrpv2.rs
+++ b/src/vrrpv2.rs
@@ -1,3 +1,4 @@
+use std::fmt::Display;
use std::io::Read;
use std::io::{self, Cursor};
use std::net::Ipv4Addr;
@@ -44,6 +45,18 @@ pub enum VRRPv2Error {
ParseError,
}
+impl Display for VRRPv2Error {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ Self::InvalidAuthType => write!(f, "Invalid Auth Type"),
+ Self::InvalidChecksum => write!(f, "Invalid Checksum"),
+ Self::InvalidType => write!(f, "Invalid Type"),
+ Self::InvalidVersion => write!(f, "Invalid Version"),
+ Self::ParseError => write!(f, "Parse Error"),
+ }
+ }
+}
+
#[derive(Debug, PartialEq)]
pub enum VRRPv2AuthType {
VRRPv2AuthNoAuth = 0x00,