feat(tvix/store): add directoryservice
This adds a DirectoryService trait, and an implementation for it using sled, and one using a HashMap. Change-Id: Ida61524b2ca949e1b3a78089a5aa7d9f9800c8d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8093 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
35ea0b0d2e
commit
3af467d7ee
4 changed files with 182 additions and 0 deletions
21
tvix/store/src/directoryservice/mod.rs
Normal file
21
tvix/store/src/directoryservice/mod.rs
Normal file
|
|
@ -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>;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue