all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Jakob Klocker <j.klocker@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox v4 1/5] pbs-api-types: implement Hash and Borrow<str> for BackupArchiveName
Date: Thu, 15 Oct 2026 14:16:55 +0200	[thread overview]
Message-ID: <20261015121659.239652-2-j.klocker@proxmox.com> (raw)
In-Reply-To: <20261015121659.239652-1-j.klocker@proxmox.com>

Sets of archive names are currently built as HashSet<String>, losing
the validation and type information BackupArchiveName provides.
Implementing Hash allows using BackupArchiveName directly as a set or
map key, and Borrow<str> keeps lookups by plain &str possible, e.g.
when matching file names read from a snapshot directory.

Suggested-by: Christian Ebner <c.ebner@proxmox.com>
Reviewed-by: Christian Ebner <c.ebner@proxmox.com>
Tested-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Jakob Klocker <j.klocker@proxmox.com>
---
 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<str> for BackupArchiveName {
     }
 }
 
+impl Borrow<str> for BackupArchiveName {
+    fn borrow(&self) -> &str {
+        &self.name
+    }
+}
+
+impl Hash for BackupArchiveName {
+    fn hash<H: Hasher>(&self, state: &mut H) {
+        self.name.hash(state)
+    }
+}
+
 impl BackupArchiveName {
     pub fn from_path(path: impl AsRef<Path>) -> Result<Self, Error> {
         let path = path.as_ref();
-- 
2.47.3




  reply	other threads:[~2026-10-15 12:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 12:16 [PATCH proxmox{,-backup} v4 0/5] fix #6990: server: drop verify state on push & pull job Jakob Klocker
2026-10-15 12:16 ` Jakob Klocker [this message]
2026-10-15 12:16 ` [PATCH proxmox-backup v4 2/5] server: pull: run blocking file operations on the blocking pool Jakob Klocker
2026-10-15 12:16 ` [PATCH proxmox-backup v4 3/5] pbs-datastore: pass expected files to cleanup_unreferenced_files Jakob Klocker
2026-10-15 12:16 ` [PATCH proxmox-backup v4 4/5] fix #6990: server: drop verify state on non-decrypt pull job Jakob Klocker
2026-10-15 12:16 ` [PATCH proxmox-backup v4 5/5] fix #6990: server: drop verify state on push job Jakob Klocker

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=20261015121659.239652-2-j.klocker@proxmox.com \
    --to=j.klocker@proxmox.com \
    --cc=pbs-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal