assemble_core/
cache.rs

1//! The cache used assemble wise. This is accessible from every project, and should be used with care
2
3use crate::ASSEMBLE_HOME;
4
5use std::ffi::OsStr;
6use std::ops::Deref;
7use std::path::{Path, PathBuf};
8
9/// The assemble cache
10pub struct AssembleCache {
11    path: PathBuf,
12}
13
14impl Default for AssembleCache {
15    /// Creates the assemble cache at `$USER_HOME/.assemble`, `$HOME/.assemble`, then `~/.assemble`
16    /// if the prior is unavailable
17    fn default() -> Self {
18        Self {
19            path: ASSEMBLE_HOME.path().join("cache"),
20        }
21    }
22}
23
24impl AsRef<Path> for AssembleCache {
25    fn as_ref(&self) -> &Path {
26        self.path.as_path()
27    }
28}
29
30impl AsRef<OsStr> for AssembleCache {
31    fn as_ref(&self) -> &OsStr {
32        self.path.as_os_str()
33    }
34}
35
36impl Deref for AssembleCache {
37    type Target = Path;
38
39    fn deref(&self) -> &Self::Target {
40        self.as_ref()
41    }
42}