pub struct CacheStore { /* private fields */ }Expand description
Reader/writer for usage.json.
Implementations§
Source§impl CacheStore
impl CacheStore
pub fn new(root: PathBuf) -> Self
pub fn path(&self) -> PathBuf
Sourcepub fn read(&self) -> Result<Option<CachedUsage>, CacheError>
pub fn read(&self) -> Result<Option<CachedUsage>, CacheError>
Return the cached entry or Ok(None) for any condition that
should degrade to a cache miss: file not present, non-UTF-8
bytes, malformed JSON, schema_version mismatch, or
cached_at in the future (clock skew). Only unexpected I/O
errors (permission denied, etc.) surface as Err.
Sourcepub fn write(&self, entry: &CachedUsage) -> Result<(), CacheError>
pub fn write(&self, entry: &CachedUsage) -> Result<(), CacheError>
Persist the entry via the atomic-rename helper. Creates the cache root on demand — no init step needed.
Sourcepub fn clear(&self) -> Result<(), CacheError>
pub fn clear(&self) -> Result<(), CacheError>
Remove the cache file. Idempotent — Ok(()) on NotFound so
callers don’t have to gate on existence first. Intended for
invalidating cached data that’s tied to a no-longer-valid
token: a still-fresh cache otherwise short-circuits the
lock-active 401 guard for up to cache_duration.
Auto Trait Implementations§
impl Freeze for CacheStore
impl RefUnwindSafe for CacheStore
impl Send for CacheStore
impl Sync for CacheStore
impl Unpin for CacheStore
impl UnsafeUnpin for CacheStore
impl UnwindSafe for CacheStore
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
Mutably borrows from an owned value. Read more