diff --git a/src/bgp/types.rs b/src/bgp/types.rs index 767a88b4..38480bd6 100644 --- a/src/bgp/types.rs +++ b/src/bgp/types.rs @@ -8,6 +8,7 @@ use serde::{Serialize, Deserialize}; typeenum!( /// AFI as used in BGP OPEN and UPDATE messages. +#[cfg_attr(feature = "serde", serde(from = "u16"))] AFI, u16, { 1 => Ipv4, @@ -17,6 +18,7 @@ typeenum!( typeenum!( /// SAFI as used in BGP OPEN and UPDATE messages. +#[cfg_attr(feature = "serde", serde(from = "u8"))] SAFI, u8, { 1 => Unicast, diff --git a/src/util/macros.rs b/src/util/macros.rs index a1b64421..cf9e55e0 100644 --- a/src/util/macros.rs +++ b/src/util/macros.rs @@ -61,9 +61,9 @@ macro_rules! typeenum { $( $x1:pat => $y1:ident ),* $(,)* })? ) => { - $(#[$attr])* #[derive(Clone, Copy, Debug, Hash, Eq, Ord, PartialEq, PartialOrd)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] + $(#[$attr])* pub enum $name { $($y),+, $($($y1($ty),)?)?