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

Hannes Laimer h.laimer at proxmox.com
Tue Sep 3 14:33:52 CEST 2024


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

diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
index dd0061ea..2ffd8488 100644
--- a/pbs-datastore/src/chunk_store.rs
+++ b/pbs-datastore/src/chunk_store.rs
@@ -18,14 +18,29 @@ use crate::file_formats::{
 };
 use crate::DataBlob;
 
+pub trait CanRead: Clone {}
+pub trait CanWrite: CanRead {}
+
+#[derive(Clone, Copy)]
+pub struct Read;
+#[derive(Clone, Copy)]
+pub struct Write;
+#[derive(Clone, Copy)]
+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.2





More information about the pbs-devel mailing list