From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 43F311FF0AF for ; Fri, 06 Nov 2026 14:15:25 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 050792162D; Fri, 06 Nov 2026 14:15:22 +0100 (CET) From: Christoph Heiss 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 Message-ID: <20261106131419.822904-3-c.heiss@proxmox.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261106131419.822904-1-c.heiss@proxmox.com> References: <20261106131419.822904-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793970874750 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.142 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: K6FO5YITP3GLWTCSAPYO365LYXAVJRLW X-Message-ID-Hash: K6FO5YITP3GLWTCSAPYO365LYXAVJRLW X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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