mod cache_internal_types;
pub mod cache_status;
pub mod first_cache;
pub mod fst_cache;
pub mod simple_hash_map_cache;
pub mod simple_vec_cache;
mod utils_parsing;
mod utils_serialization;
pub use self::cache_status::CacheStatus;
pub use self::first_cache::FirstCache;
pub use self::fst_cache::FstCache;
pub use self::simple_hash_map_cache::SimpleHashMapCache;
pub use self::simple_vec_cache::SimpleVecCache;
use anyhow::Result;
use std::path::Path;
use std::sync::Arc;
pub trait SerializableCache {
fn read<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized;
fn write<P: AsRef<Path>>(&self, path: P) -> Result<()>;
}
impl<C: SerializableCache> SerializableCache for Arc<C> {
fn read<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized,
{
Ok(Arc::new(C::read(path)?))
}
fn write<P: AsRef<Path>>(&self, path: P) -> Result<()> {
(**self).write(path)
}
}