Skip to main content

PackageCache

Struct PackageCache 

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

High-performance package payload cache.

This struct manages a disk-based cache of package variant payloads, enabling fast environment resolution without fetching from shared storage.

§Example

use rez_next_package::package_cache::PackageCache;

let cache = PackageCache::new("/path/to/cache").unwrap();

Implementations§

Source§

impl PackageCache

Source

pub fn new<P: AsRef<Path>>(path: P) -> Result<Self, PackageCacheError>

Create a new package cache at the given root path.

§Errors

Returns PackageCacheError::NotADirectory if path is not an existing directory.

Source

pub fn with_config<P: AsRef<Path>>( path: P, config: CacheConfig, ) -> Result<Self, PackageCacheError>

Create with custom configuration.

Source

pub fn root(&self) -> &Path

Get the root path of the cache.

Source

pub fn config(&self) -> &CacheConfig

Get the configuration.

Source

pub fn get_cached_root( &self, handle: &VariantHandle, ) -> (CacheStatus, Option<PathBuf>)

Check if a variant is cached and return its root path.

Updates the last-accessed time on the cache entry.

§Returns

(CacheStatus, Option<PathBuf>) - status and path if found.

Source

pub fn add_variant( &self, handle: &VariantHandle, source_root: &Path, force: bool, ) -> Result<(CacheStatus, PathBuf), PackageCacheError>

Add a variant’s payload to the cache.

Copies the payload from source_root to the cache.

§Arguments
  • handle - The variant handle
  • source_root - Path to the variant’s payload on disk
  • force - Force caching even if checks fail
§Returns

(CacheStatus, PathBuf) - final status and cache path.

Source

pub fn remove_variant( &self, handle: &VariantHandle, ) -> (CacheStatus, Option<PathBuf>)

Remove a variant from the cache.

Moves the payload to the to_delete directory; actual deletion happens during clean().

Source

pub fn list_cached(&self) -> Vec<(VariantHandle, PathBuf, CacheStatus)>

List all cached variants.

Returns a list of (handle, path, status) tuples.

Source

pub fn clean(&self, time_limit_secs: Option<u64>) -> CleanStats

Clean the cache by removing:

  • Old unused entries (based on max_age_secs)
  • Stalled copies
  • Entries in to_delete directory
§Arguments
  • time_limit_secs - Optional time limit for cleaning operation
Source

pub fn cache_near_full(&self) -> bool

Check if the cache disk is near full.

Returns true if available space is below min_free_space_bytes. Aligns with rez.package_cache.PackageCache.cache_near_full().

Source

pub fn variant_meets_space_requirements(&self, variant_root: &Path) -> bool

Check if adding a variant would leave enough free space.

Aligns with rez.package_cache.PackageCache.variant_meets_space_requirements().

§Arguments
  • variant_root - Path to the variant’s payload
§Returns

true if there’s enough space to cache this variant.

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, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U