[pbs-devel] [PATCH proxmox-backup v2 01/12] chunkstore: add CanRead and CanWrite trait

Hannes Laimer h.laimer at proxmox.com
Mon May 26 16:14:34 CEST 2025


Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
---
 pbs-datastore/src/chunk_store.rs | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index 29a3d477..9a77bef2 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -21,14 +21,36 @@ use crate::file_formats::{
 };
 use crate::DataBlob;
 
+mod private {
+    pub trait Sealed: Clone + Copy {}
+    impl Sealed for super::Read {}
+    impl Sealed for super::Write {}
+    impl Sealed for super::Lookup {}
+}
+
+pub trait CanRead: private::Sealed {}
+pub trait CanWrite: CanRead + private::Sealed {}
+
+#[derive(Clone, Copy, Debug)]
+pub struct Read;
+#[derive(Clone, Copy, Debug)]
+pub struct Write;
+#[derive(Clone, Copy, Debug)]
+pub struct Lookup;
+
+impl CanRead for Read {}
+impl CanRead for Write {}
+impl CanWrite for Write {}
+
 /// File system based chunk store
-pub struct ChunkStore {
+pub struct ChunkStore<T> {
     name: String, // used for error reporting
     pub(crate) base: PathBuf,
     chunk_dir: PathBuf,
     mutex: Mutex<()>,
     locker: Option<Arc<Mutex<ProcessLocker>>>,
     sync_level: DatastoreFSyncLevel,
+    _marker: std::marker::PhantomData<T>,
 }
 
 // TODO: what about sysctl setting vm.vfs_cache_pressure (0 - 100) ?
-- 
2.39.5





More information about the pbs-devel mailing list