[pve-devel] [PATCH proxmox-ve-rs v3 7/7] add derive PartialEq, Eq and HashMap->BTreeMap for tests

Stefan Hanreich s.hanreich at proxmox.com
Fri Nov 7 15:31:23 CET 2025


From: Gabriel Goller <g.goller at proxmox.com>

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 proxmox-frr/src/de/evpn.rs       |  4 ++--
 proxmox-frr/src/de/mod.rs        | 10 +++++-----
 proxmox-frr/src/de/openfabric.rs | 22 +++++++++++-----------
 proxmox-frr/src/de/ospf.rs       | 16 ++++++++--------
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/proxmox-frr/src/de/evpn.rs b/proxmox-frr/src/de/evpn.rs
index 97faca4..942aecf 100644
--- a/proxmox-frr/src/de/evpn.rs
+++ b/proxmox-frr/src/de/evpn.rs
@@ -1,4 +1,4 @@
-use std::{collections::HashMap, net::IpAddr};
+use std::{collections::BTreeMap, net::IpAddr};
 
 use proxmox_network_types::mac_address::MacAddress;
 use serde::Deserialize;
@@ -6,7 +6,7 @@ use serde_repr::Deserialize_repr;
 
 /// All EVPN routes
 #[derive(Debug, Default, Deserialize)]
-pub struct Routes(pub HashMap<String, Entry>);
+pub struct Routes(pub BTreeMap<String, Entry>);
 
 /// The evpn routes a stored in a hashtable, which has a numPrefix and numPath key at
 /// the end which stores the number of paths and prefixes. These two keys have a i32
diff --git a/proxmox-frr/src/de/mod.rs b/proxmox-frr/src/de/mod.rs
index 121451b..3f2bd68 100644
--- a/proxmox-frr/src/de/mod.rs
+++ b/proxmox-frr/src/de/mod.rs
@@ -1,4 +1,4 @@
-use std::{collections::HashMap, net::IpAddr};
+use std::{collections::BTreeMap, net::IpAddr};
 
 use proxmox_network_types::ip_address::Cidr;
 use serde::{Deserialize, Serialize};
@@ -8,7 +8,7 @@ pub mod openfabric;
 pub mod ospf;
 
 /// A nexthop of a route
-#[derive(Debug, Serialize, Deserialize, Clone)]
+#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
 pub struct NextHop {
     /// IP of the nexthop
     pub ip: Option<IpAddr>,
@@ -24,7 +24,7 @@ pub struct NextHop {
 }
 
 /// route
-#[derive(Debug, Serialize, Deserialize, Clone)]
+#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
 pub struct Route {
     /// Array of all the nexthops associated with this route. When you have e.g. two
     /// connections between two nodes, there is going to be one route, but two nexthops.
@@ -45,5 +45,5 @@ pub struct Route {
 /// routes we simply ask zebra which routes have been inserted and filter them by protocol.
 /// The following command is used to accomplish this: `show ip route <protocol> json`.
 /// This struct can be used the deserialize the output of that command.
-#[derive(Debug, Serialize, Deserialize, Default)]
-pub struct Routes(pub HashMap<Cidr, Vec<Route>>);
+#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
+pub struct Routes(pub BTreeMap<Cidr, Vec<Route>>);
diff --git a/proxmox-frr/src/de/openfabric.rs b/proxmox-frr/src/de/openfabric.rs
index 837159b..f4d522f 100644
--- a/proxmox-frr/src/de/openfabric.rs
+++ b/proxmox-frr/src/de/openfabric.rs
@@ -1,7 +1,7 @@
 use serde::{Deserialize, Serialize};
 
 /// State of the adjacency of a OpenFabric neighbor
-#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
 pub enum AdjacencyState {
     Initializing,
     Up,
@@ -12,7 +12,7 @@ pub enum AdjacencyState {
 /// Neighbor Interface
 ///
 /// Interface used to communicate with a specific neighbor
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 pub struct NeighborInterface {
     /// The name of the interface
     pub name: String,
@@ -26,7 +26,7 @@ pub struct NeighborInterface {
 /// Adjacency information
 ///
 /// Circuits are Layer-2 Broadcast domains (Either point-to-point or LAN).
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 pub struct Circuit {
     /// The hostname of the adjacency peer
     pub adj: Option<String>,
@@ -35,7 +35,7 @@ pub struct Circuit {
 }
 
 /// An openfabric area the same as SDN fabric.
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 pub struct Area {
     /// The are name, this is the same as the fabric_id, so the name of the fabric.
     pub area: String,
@@ -47,14 +47,14 @@ pub struct Area {
 ///
 /// This models the output of:
 /// `vtysh -c 'show openfabric neighbor json'`.
-#[derive(Debug, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
 pub struct Neighbors {
     /// Every sdn fabric is also an openfabric 'area'
     pub areas: Vec<Area>,
 }
 
 /// The NetworkType of a OpenFabric interface
-#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
 pub enum NetworkType {
     #[serde(rename(deserialize = "p2p", serialize = "Point-To-Point"))]
     PointToPoint,
@@ -67,7 +67,7 @@ pub enum NetworkType {
 }
 
 /// The State of a OpenFabric interface
-#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
 pub enum CircuitState {
     Init,
     Config,
@@ -75,7 +75,7 @@ pub enum CircuitState {
     Unknown,
 }
 
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 #[serde(rename_all = "kebab-case")]
 pub struct Interface {
     pub name: String,
@@ -84,18 +84,18 @@ pub struct Interface {
     pub ty: NetworkType,
 }
 
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 pub struct InterfaceCircuits {
     pub interface: Interface,
 }
 
-#[derive(Debug, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
 pub struct InterfaceArea {
     pub area: String,
     pub circuits: Vec<InterfaceCircuits>,
 }
 
-#[derive(Debug, Serialize, Deserialize, Default)]
+#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
 pub struct Interfaces {
     pub areas: Vec<InterfaceArea>,
 }
diff --git a/proxmox-frr/src/de/ospf.rs b/proxmox-frr/src/de/ospf.rs
index 7e269fe..c3a6f81 100644
--- a/proxmox-frr/src/de/ospf.rs
+++ b/proxmox-frr/src/de/ospf.rs
@@ -1,9 +1,9 @@
-use std::collections::HashMap;
+use std::collections::BTreeMap;
 
 use serde::{Deserialize, Serialize};
 
 /// Information about the Neighbor (Peer) of the Adjacency.
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
 #[serde(rename_all = "camelCase")]
 pub struct Neighbor {
     /// The full state of the neighbor. This is "{converged}/{role}".
@@ -25,14 +25,14 @@ pub struct Neighbor {
 }
 
 /// The parsed OSPF neighbors
-#[derive(Debug, Deserialize, Default)]
+#[derive(Debug, Clone, Deserialize, Default, PartialEq, Eq)]
 pub struct Neighbors {
     /// The OSPF neighbors. This is nearly always a ip-address - neighbor mapping.
-    pub neighbors: HashMap<String, Vec<Neighbor>>,
+    pub neighbors: BTreeMap<String, Vec<Neighbor>>,
 }
 
 /// All possible OSPF network-types that can be returned from frr
-#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
 pub enum NetworkType {
     #[serde(rename = "Null")]
     Null,
@@ -50,7 +50,7 @@ pub enum NetworkType {
     Loopback,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
 #[serde(rename_all = "camelCase")]
 pub struct Interface {
     /// The interface state
@@ -64,7 +64,7 @@ pub struct Interface {
     pub network_type: NetworkType,
 }
 
-#[derive(Debug, Deserialize, Default)]
+#[derive(Debug, Clone, Deserialize, Default, PartialEq, Eq)]
 pub struct Interfaces {
-    pub interfaces: HashMap<String, Interface>,
+    pub interfaces: BTreeMap<String, Interface>,
 }
-- 
2.47.3




More information about the pve-devel mailing list