mod actor; mod handle_impl; mod message; pub mod store; use std::collections::HashSet; use std::path::PathBuf; use thiserror::Error; use uuid::Uuid; use actor::UuidResolverActor; use message::UuidResolveMsg; use store::UuidStore; #[cfg(test)] use mockall::automock; pub use handle_impl::UuidResolverHandleImpl; pub use store::HeedUuidStore; const UUID_STORE_SIZE: usize = 1_073_741_824; //1GiB pub type Result = std::result::Result; #[async_trait::async_trait] #[cfg_attr(test, automock)] pub trait UuidResolverHandle { async fn get(&self, name: String) -> Result; async fn insert(&self, name: String, uuid: Uuid) -> anyhow::Result<()>; async fn delete(&self, name: String) -> anyhow::Result; async fn list(&self) -> anyhow::Result>; async fn snapshot(&self, path: PathBuf) -> Result>; async fn get_size(&self) -> Result; async fn dump(&self, path: PathBuf) -> Result>; } #[derive(Debug, Error)] pub enum UuidResolverError { #[error("Name already exist.")] NameAlreadyExist, #[error("Index \"{0}\" doesn't exist.")] UnexistingIndex(String), #[error("Badly formatted index uid: {0}")] BadlyFormatted(String), #[error("Internal error resolving index uid: {0}")] Internal(String), } macro_rules! internal_error { ($($other:path), *) => { $( impl From<$other> for UuidResolverError { fn from(other: $other) -> Self { Self::Internal(other.to_string()) } } )* } } internal_error!( heed::Error, uuid::Error, std::io::Error, tokio::task::JoinError, serde_json::Error );