From afc0890b158729d3191904c002448a989498c61c Mon Sep 17 00:00:00 2001 From: Andreas Loydold Date: Wed, 16 Dec 2020 14:59:01 +0100 Subject: [PATCH 1/2] add serialization attributes for MacAddr enum --- src/addr.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/addr.rs b/src/addr.rs index d761bdd..6a20f65 100644 --- a/src/addr.rs +++ b/src/addr.rs @@ -4,6 +4,7 @@ use crate::{parser, MacAddr6, MacAddr8, ParseError}; /// A MAC address, either in *EUI-48* or *EUI-64* format. #[derive(Debug, Hash, Eq, PartialEq, Ord, PartialOrd, Copy, Clone)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum MacAddr { V6(MacAddr6), V8(MacAddr8), From 3c9a5ab2cd1162d48f87f24c20bc40768ed6d8f4 Mon Sep 17 00:00:00 2001 From: Andreas Loydold Date: Wed, 16 Dec 2020 17:10:23 +0100 Subject: [PATCH 2/2] use untagged enum representation for MacAddr serialization --- src/addr.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/addr.rs b/src/addr.rs index 6a20f65..7fc52b8 100644 --- a/src/addr.rs +++ b/src/addr.rs @@ -5,6 +5,7 @@ use crate::{parser, MacAddr6, MacAddr8, ParseError}; /// A MAC address, either in *EUI-48* or *EUI-64* format. #[derive(Debug, Hash, Eq, PartialEq, Ord, PartialOrd, Copy, Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum MacAddr { V6(MacAddr6), V8(MacAddr8),