public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH proxmox v2 2/7] network-types: derive Display and FromStr for network bond types
Date: Fri,  6 Nov 2026 14:14:13 +0100	[thread overview]
Message-ID: <20261106131419.822904-3-c.heiss@proxmox.com> (raw)
In-Reply-To: <20261106131419.822904-1-c.heiss@proxmox.com>

Since the names implemented manually through the Display trait are equal
to the serde-serialized variants, use serde_plain for that too.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Extracted and rebased from the original pve-installer series, as the
rest for `proxmox` has been applied.

Changes v1 -> v2:
  * new patch

 proxmox-network-types/src/bond.rs | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/proxmox-network-types/src/bond.rs b/proxmox-network-types/src/bond.rs
index b31e3984..a49de317 100644
--- a/proxmox-network-types/src/bond.rs
+++ b/proxmox-network-types/src/bond.rs
@@ -1,7 +1,5 @@
 //! Types for Linux bonding interfaces.
 
-use std::fmt;
-
 use serde::{Deserialize, Serialize};
 
 #[cfg(feature = "api-types")]
@@ -30,19 +28,8 @@ pub enum LinuxBondMode {
     BalanceAlb = 6,
 }
 
-impl fmt::Display for LinuxBondMode {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.write_str(match self {
-            LinuxBondMode::BalanceRr => "balance-rr",
-            LinuxBondMode::ActiveBackup => "active-backup",
-            LinuxBondMode::BalanceXor => "balance-xor",
-            LinuxBondMode::Broadcast => "broadcast",
-            LinuxBondMode::Ieee802_3ad => "802.3ad",
-            LinuxBondMode::BalanceTlb => "balance-tlb",
-            LinuxBondMode::BalanceAlb => "balance-alb",
-        })
-    }
-}
+serde_plain::derive_display_from_serialize!(LinuxBondMode);
+serde_plain::derive_fromstr_from_deserialize!(LinuxBondMode);
 
 #[cfg_attr(feature = "api-types", api())]
 #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -60,12 +47,5 @@ pub enum BondXmitHashPolicy {
     Layer3_4 = 2,
 }
 
-impl fmt::Display for BondXmitHashPolicy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.write_str(match self {
-            BondXmitHashPolicy::Layer2 => "layer2",
-            BondXmitHashPolicy::Layer2_3 => "layer2+3",
-            BondXmitHashPolicy::Layer3_4 => "layer3+4",
-        })
-    }
-}
+serde_plain::derive_display_from_serialize!(BondXmitHashPolicy);
+serde_plain::derive_fromstr_from_deserialize!(BondXmitHashPolicy);
-- 
2.56.0





  parent reply	other threads:[~2026-11-06 13:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 13:14 [PATCH datacenter-manager/proxmox v2 0/7] auto-install: add support for VLAN and bond configurations Christoph Heiss
2026-11-06 13:14 ` [PATCH proxmox v2 1/7] installer-types: derive Display for RebootMode and FilterMatch Christoph Heiss
2026-11-06 13:14 ` Christoph Heiss [this message]
2026-11-06 13:14 ` [PATCH datacenter-manager v2 3/7] config: auto-install: add new options for configuring vlan and bond Christoph Heiss
2026-11-06 13:14 ` [PATCH datacenter-manager v2 4/7] api-types: auto-installer: " Christoph Heiss
2026-11-06 13:14 ` [PATCH datacenter-manager v2 5/7] api: auto-installer: wire up new vlan and bond network options Christoph Heiss
2026-11-06 13:14 ` [PATCH datacenter-manager v2 6/7] ui: auto-installer: use .to_string() instead of manual serde variant Christoph Heiss
2026-11-06 13:14 ` [PATCH datacenter-manager v2 7/7] ui: auto-installer: add vlan and bond config as advanced options Christoph Heiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261106131419.822904-3-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal