pub struct RomCache { /* private fields */ }Expand description
In-memory view of the persisted ROM cache.
Internally this is just a HashMap keyed by RomCacheKey, plus the
path of the JSON file on disk. All callers go through RomCache::load
so they never touch the filesystem directly.
Implementations§
Source§impl RomCache
impl RomCache
Sourcepub fn effective_path() -> PathBuf
pub fn effective_path() -> PathBuf
Effective ROM cache path (ROMM_CACHE_PATH override wins over OS-local default).
Sourcepub fn clear_file() -> Result<bool>
pub fn clear_file() -> Result<bool>
Remove the cache file from disk if it exists.
Sourcepub fn read_info() -> RomCacheInfo
pub fn read_info() -> RomCacheInfo
Read best-effort metadata and parse information for the current cache file.
Sourcepub fn get_valid(
&self,
key: &RomCacheKey,
expected_count: u64,
) -> Option<&RomList>
pub fn get_valid( &self, key: &RomCacheKey, expected_count: u64, ) -> Option<&RomList>
Return cached data only if the platform’s rom_count hasn’t changed
since we cached it. We compare the stored count (from the platforms
endpoint at cache time) against the current count — NOT RomList.total,
which can legitimately differ from rom_count.
Sourcepub fn insert(&mut self, key: RomCacheKey, data: RomList, expected_count: u64)
pub fn insert(&mut self, key: RomCacheKey, data: RomList, expected_count: u64)
Insert (or replace) an entry, then persist to disk.
expected_count is the platform/collection rom_count at this moment.
Sourcepub fn remove(&mut self, key: &RomCacheKey) -> bool
pub fn remove(&mut self, key: &RomCacheKey) -> bool
Drop one cache entry if present, then persist.
Sourcepub fn remove_all_platform_entries(&mut self) -> usize
pub fn remove_all_platform_entries(&mut self) -> usize
Remove every RomCacheKey::Platform entry (e.g. after a full scan_library).
Auto Trait Implementations§
impl Freeze for RomCache
impl RefUnwindSafe for RomCache
impl Send for RomCache
impl Sync for RomCache
impl Unpin for RomCache
impl UnsafeUnpin for RomCache
impl UnwindSafe for RomCache
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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