1use std::path::{Path, PathBuf};
10
11pub mod cached_cdn_client;
12pub mod cached_ribbit_client;
13pub mod cached_tact_client;
14pub mod cdn;
15pub mod error;
16pub mod generic;
17pub mod hybrid_version_client;
18pub mod ribbit;
19pub mod stats;
20
21pub use cdn::CdnCache;
22pub use error::{Error, Result};
23pub use stats::{CacheReport, CacheStats, CacheStatsSnapshot};
24
25pub fn get_cache_dir() -> Result<PathBuf> {
32 dirs::cache_dir()
33 .ok_or(Error::CacheDirectoryNotFound)
34 .map(|dir| dir.join("ngdp"))
35}
36
37pub(crate) async fn ensure_dir(path: &Path) -> Result<()> {
39 if tokio::fs::metadata(path).await.is_err() {
40 tokio::fs::create_dir_all(path).await?;
41 }
42 Ok(())
43}