pub struct DiskCache { /* private fields */ }Expand description
An opened, authenticated cache directory.
Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub fn open(
dir: impl Into<PathBuf>,
limits: CacheLimits,
) -> Result<Self, OpenError>
pub fn open( dir: impl Into<PathBuf>, limits: CacheLimits, ) -> Result<Self, OpenError>
Open (creating if necessary) the cache directory at dir.
Fails — meaning disable the cache, not fall back to unauthenticated reads — when the directory belongs to another user, when it cannot be made private, or when the key file is absent-and-uncreatable, the wrong length, or readable by anyone but the owner.
Sourcepub fn limits(&self) -> CacheLimits
pub fn limits(&self) -> CacheLimits
The budget this cache was opened with.
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Snapshot of the counters.
Sourcepub fn load(&self, key: &str) -> Option<CachedScan>
pub fn load(&self, key: &str) -> Option<CachedScan>
Load and authenticate the entry for key.
Every failure path — absent, expired, oversized, truncated, wrong
magic, bad tag, or a body that does not validate — returns None.
A tag mismatch also warns on stderr and bumps
CacheStats::tampered.
Sourcepub fn store(&self, key: &str, scan: &CachedScan) -> Result<(), String>
pub fn store(&self, key: &str, scan: &CachedScan) -> Result<(), String>
Store scan under key, atomically and authenticated.
Sourcepub fn purge(&self) -> Result<(u64, u64), String>
pub fn purge(&self) -> Result<(u64, u64), String>
Delete every entry. Returns (files, bytes) removed. The key file
survives, so a purge does not invalidate anything an operator has
backed up out of band — it just empties the cache.
Sourcepub fn size_on_disk(&self) -> Result<u64, String>
pub fn size_on_disk(&self) -> Result<u64, String>
Total bytes currently held by entries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DiskCache
impl RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnsafeUnpin for DiskCache
impl UnwindSafe for DiskCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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