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 1E6EE1FF0BC for ; Thu, 15 Oct 2026 14:17:08 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id BF84F21449; Thu, 15 Oct 2026 14:17:03 +0200 (CEST) From: Jakob Klocker To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox v4 1/5] pbs-api-types: implement Hash and Borrow for BackupArchiveName Date: Thu, 15 Oct 2026 14:16:55 +0200 Message-ID: <20261015121659.239652-2-j.klocker@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261015121659.239652-1-j.klocker@proxmox.com> References: <20261015121659.239652-1-j.klocker@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.678 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) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: 6WOUKHAVGS2AE4GYP7N45SFJDXVESDP5 X-Message-ID-Hash: 6WOUKHAVGS2AE4GYP7N45SFJDXVESDP5 X-MailFrom: jklocker@dev.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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Sets of archive names are currently built as HashSet, losing the validation and type information BackupArchiveName provides. Implementing Hash allows using BackupArchiveName directly as a set or map key, and Borrow keeps lookups by plain &str possible, e.g. when matching file names read from a snapshot directory. Suggested-by: Christian Ebner Reviewed-by: Christian Ebner Tested-by: Christian Ebner Signed-off-by: Jakob Klocker --- pbs-api-types/src/datastore.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 93ccaf07..39ff5e9a 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1,5 +1,7 @@ +use std::borrow::Borrow; use std::convert::{AsRef, TryFrom}; use std::fmt; +use std::hash::{Hash, Hasher}; use std::path::{Path, PathBuf}; use std::str::FromStr; use std::sync::LazyLock; @@ -2139,6 +2141,18 @@ impl AsRef for BackupArchiveName { } } +impl Borrow for BackupArchiveName { + fn borrow(&self) -> &str { + &self.name + } +} + +impl Hash for BackupArchiveName { + fn hash(&self, state: &mut H) { + self.name.hash(state) + } +} + impl BackupArchiveName { pub fn from_path(path: impl AsRef) -> Result { let path = path.as_ref(); -- 2.47.3