about summary refs log tree commit diff
path: root/tvix/store/src/directoryservice/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/directoryservice/mod.rs')
-rw-r--r--tvix/store/src/directoryservice/mod.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tvix/store/src/directoryservice/mod.rs b/tvix/store/src/directoryservice/mod.rs
new file mode 100644
index 0000000000..4abf823b23
--- /dev/null
+++ b/tvix/store/src/directoryservice/mod.rs
@@ -0,0 +1,21 @@
+use crate::{proto, Error};
+mod memory;
+mod sled;
+
+pub use self::memory::MemoryDirectoryService;
+pub use self::sled::SledDirectoryService;
+
+/// The base trait all Directory services need to implement.
+/// This is a simple get and put of [crate::proto::Directory], returning their
+/// digest.
+pub trait DirectoryService {
+    /// Get looks up a single Directory message by its digest.
+    /// In case the directory is not found, Ok(None) is returned.
+    fn get(
+        &self,
+        by_what: &proto::get_directory_request::ByWhat,
+    ) -> Result<Option<proto::Directory>, Error>;
+    /// Get uploads a single Directory message, and returns the calculated
+    /// digest, or an error.
+    fn put(&self, directory: proto::Directory) -> Result<Vec<u8>, Error>;
+}