Skip to main content

CacheGroup

Struct CacheGroup 

Source
pub struct CacheGroup { /* private fields */ }
Expand description

A group (subdirectory) under a CacheRoot that manages cache entries.

Use CacheRoot::group(...) to construct a CacheGroup rooted under a CacheRoot.

Implementations§

Source§

impl CacheGroup

Source

pub fn path(&self) -> &Path

Return the path of this cache group.

Source

pub fn ensure_dir(&self) -> Result<&Path>

Ensure the group directory exists on disk, creating parents as needed.

Source

pub fn ensure_dir_with_policy( &self, policy: Option<&EvictPolicy>, ) -> Result<&Path>

Ensures this directory exists, then applies optional eviction.

Eviction is applied recursively to files under this directory. The policy is best-effort for removals: individual delete failures are ignored so initialization can continue.

Source

pub fn eviction_report(&self, policy: &EvictPolicy) -> Result<EvictionReport>

Returns a report of files that would be evicted under policy.

This does not delete files. The selection order matches the internal order used by ensure_dir_with_policy. Return a report of files that would be evicted by policy.

The report is non-destructive and mirrors the selection used by ensure_dir_with_policy so it can be used for previewing or testing.

Source

pub fn subgroup<P: AsRef<Path>>(&self, relative_group: P) -> Self

Create a nested subgroup under this group.

Source

pub fn entry_path<P: AsRef<Path>>(&self, relative_file: P) -> PathBuf

Resolve a relative entry path under this group.

Source

pub fn touch<P: AsRef<Path>>(&self, relative_file: P) -> Result<PathBuf>

Create or update (touch) a file under this group, creating parent directories as needed. Returns the absolute path to the entry.

Trait Implementations§

Source§

impl Clone for CacheGroup

Source§

fn clone(&self) -> CacheGroup

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CacheGroup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CacheGroup

Source§

impl PartialEq for CacheGroup

Source§

fn eq(&self, other: &CacheGroup) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for CacheGroup

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.