pub struct CacheRoot { /* private fields */ }Expand description
Represents a discovered or explicit cache root directory.
Use CacheRoot::discover() to find the nearest crate root from the
current working directory, or CacheRoot::from_root(...) to construct one
from an explicit path.
Implementations§
Source§impl CacheRoot
impl CacheRoot
Sourcepub fn discover() -> Result<Self>
pub fn discover() -> Result<Self>
Discover the cache root by searching parent directories for Cargo.toml.
Falls back to the current working directory when no crate root is found.
Sourcepub fn from_root<P: Into<PathBuf>>(root: P) -> Self
pub fn from_root<P: Into<PathBuf>>(root: P) -> Self
Create a CacheRoot from an explicit filesystem path.
Sourcepub fn discover_or_cwd() -> Self
pub fn discover_or_cwd() -> Self
Like discover() but never returns an io::Result — falls back to . on error.
Sourcepub fn group<P: AsRef<Path>>(&self, relative_group: P) -> CacheGroup
pub fn group<P: AsRef<Path>>(&self, relative_group: P) -> CacheGroup
Build a CacheGroup for a relative subdirectory under this root.
Sourcepub fn group_path<P: AsRef<Path>>(&self, relative_group: P) -> PathBuf
pub fn group_path<P: AsRef<Path>>(&self, relative_group: P) -> PathBuf
Resolve a relative group path to an absolute PathBuf under this root.
Sourcepub fn ensure_group<P: AsRef<Path>>(&self, relative_group: P) -> Result<PathBuf>
pub fn ensure_group<P: AsRef<Path>>(&self, relative_group: P) -> Result<PathBuf>
Ensure the given group directory exists, creating parents as required.
Sourcepub fn ensure_group_with_policy<P: AsRef<Path>>(
&self,
relative_group: P,
policy: Option<&EvictPolicy>,
) -> Result<PathBuf>
pub fn ensure_group_with_policy<P: AsRef<Path>>( &self, relative_group: P, policy: Option<&EvictPolicy>, ) -> Result<PathBuf>
Ensure the given group exists and optionally apply an eviction policy.
When policy is Some, files will be evaluated and removed according
to the EvictPolicy rules. Passing None performs only directory creation.