2023-02-12 14:24:43 +01:00
|
|
|
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.
|
2023-03-16 00:01:30 +01:00
|
|
|
fn get(&self, digest: &[u8; 32]) -> Result<Option<proto::Directory>, Error>;
|
2023-02-12 14:24:43 +01:00
|
|
|
/// Get uploads a single Directory message, and returns the calculated
|
|
|
|
/// digest, or an error.
|
2023-03-16 00:01:30 +01:00
|
|
|
fn put(&self, directory: proto::Directory) -> Result<[u8; 32], Error>;
|
2023-02-12 14:24:43 +01:00
|
|
|
}
|