From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 9DDA01FF09C for ; Mon, 02 Nov 2026 13:47:08 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E0C7521809; Mon, 02 Nov 2026 13:46:39 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox v4 08/30] network-api: derive Display and FromStr for network bond types Date: Mon, 2 Nov 2026 13:45:14 +0100 Message-ID: <20261102124539.1008075-9-c.heiss@proxmox.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261102124539.1008075-1-c.heiss@proxmox.com> References: <20261102124539.1008075-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: 1793623585292 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.218 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: BIUAW333CLOPDKJD2WL3KUJQSPF35UEC X-Message-ID-Hash: BIUAW333CLOPDKJD2WL3KUJQSPF35UEC 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 VE 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 --- Needed by the PDM UI. Changes v3 -> v4: * new patch proxmox-network-api/Cargo.toml | 1 + proxmox-network-api/debian/control | 6 ++++-- proxmox-network-api/src/api_types.rs | 27 ++++----------------------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/proxmox-network-api/Cargo.toml b/proxmox-network-api/Cargo.toml index 3fd89ef3..b8af7afd 100644 --- a/proxmox-network-api/Cargo.toml +++ b/proxmox-network-api/Cargo.toml @@ -18,6 +18,7 @@ regex.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true +serde_plain.workspace = true nix = { workspace = true, optional = true } libc = { workspace = true, optional = true } diff --git a/proxmox-network-api/debian/control b/proxmox-network-api/debian/control index b7277b3f..3c92c180 100644 --- a/proxmox-network-api/debian/control +++ b/proxmox-network-api/debian/control @@ -15,7 +15,8 @@ Build-Depends-Arch: cargo:native , librust-regex-1+default-dev (>= 1.5-~~) , librust-serde-1+default-dev , librust-serde-1+derive-dev , - librust-serde-json-1+default-dev + librust-serde-json-1+default-dev , + librust-serde-plain-1+default-dev Maintainer: Proxmox Support Team Standards-Version: 4.7.2 Vcs-Git: git://git.proxmox.com/git/proxmox.git @@ -37,7 +38,8 @@ Depends: librust-regex-1+default-dev (>= 1.5-~~), librust-serde-1+default-dev, librust-serde-1+derive-dev, - librust-serde-json-1+default-dev + librust-serde-json-1+default-dev, + librust-serde-plain-1+default-dev Suggests: librust-proxmox-network-api+impl-dev (= ${binary:Version}) Provides: diff --git a/proxmox-network-api/src/api_types.rs b/proxmox-network-api/src/api_types.rs index f2467f1e..6e3e2651 100644 --- a/proxmox-network-api/src/api_types.rs +++ b/proxmox-network-api/src/api_types.rs @@ -1,4 +1,3 @@ -use std::fmt; use std::sync::LazyLock; use anyhow::{Error, bail}; @@ -64,19 +63,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); #[api()] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -94,15 +82,8 @@ 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); #[api()] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] -- 2.55.0