Creates a new [`CacheDir`] from XDG default location. Defaults to `$XDG_CACHE_HOME/alpm/testing`. If `$XDG_CACHE_HOME` is unset, falls back to `~/.cache/alpm/testing`. # Errors Returns an error if the cache directory for the current user cannot be retrieved.
()
| 23 | /// |
| 24 | /// Returns an error if the cache directory for the current user cannot be retrieved. |
| 25 | pub fn from_xdg() -> Result<Self, Error> { |
| 26 | let path = cache_dir() |
| 27 | .ok_or(Error::CannotGetCacheDir)? |
| 28 | .join(PROJECT_NAME) |
| 29 | .join(TESTING_DIR); |
| 30 | debug!("Using path {path:?} as cache dir."); |
| 31 | |
| 32 | Ok(Self(path)) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl From<PathBuf> for CacheDir { |