[pdm-devel] [PATCH proxmox-datacenter-manager v2 07/15] ui: sdn: add EvpnRouteTarget type

Stefan Hanreich s.hanreich at proxmox.com
Fri Aug 22 15:49:30 CEST 2025


A helper type that can be used to parse the route targets contained in
the EVPN zones 'Route Target Import' API call.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 ui/src/sdn/evpn/mod.rs | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 ui/src/sdn/evpn/mod.rs

diff --git a/ui/src/sdn/evpn/mod.rs b/ui/src/sdn/evpn/mod.rs
new file mode 100644
index 0000000..2515354
--- /dev/null
+++ b/ui/src/sdn/evpn/mod.rs
@@ -0,0 +1,26 @@
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)]
+pub struct EvpnRouteTarget {
+    asn: u32,
+    vni: u32,
+}
+
+impl std::str::FromStr for EvpnRouteTarget {
+    type Err = anyhow::Error;
+
+    fn from_str(value: &str) -> Result<Self, Self::Err> {
+        if let Some((asn, vni)) = value.split_once(':') {
+            return Ok(Self {
+                asn: asn.parse()?,
+                vni: vni.parse()?,
+            });
+        }
+
+        anyhow::bail!("could not parse EVPN route target!")
+    }
+}
+
+impl std::fmt::Display for EvpnRouteTarget {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+        write!(f, "{}:{}", self.asn, self.vni)
+    }
+}
-- 
2.47.2




More information about the pdm-devel mailing list