pub struct ImageCache { /* private fields */ }Implementations§
Source§impl ImageCache
impl ImageCache
pub fn new(root: PathBuf) -> Self
pub fn read(&self, key: &str) -> Option<Vec<u8>>
pub fn contains(&self, key: &str) -> bool
pub async fn get_or_fetch(&self, key: &str) -> Option<Vec<u8>>
pub async fn preseed(&self, keys: &[String]) -> PreseedResult
Sourcepub fn check_room_for(&self, estimate_bytes: u64) -> Result<(), String>
pub fn check_room_for(&self, estimate_bytes: u64) -> Result<(), String>
The estimate comes from the caller: the per-variant sizes are measured in the UI and a second copy here could disagree.
pub fn stats(&self) -> CacheStats
Sourcepub fn reconcile(&self)
pub fn reconcile(&self)
The one full walk, at startup, and the only place .part files left by a
cancelled download are swept.
pub fn clear(&self, include_pinned: bool) -> Result<(), String>
Source§impl ImageCache
impl ImageCache
Sourcepub async fn download_all(
&self,
variants: &[String],
estimate_bytes: u64,
progress: impl Fn(BulkProgress),
) -> Result<PreseedResult, String>
pub async fn download_all( &self, variants: &[String], estimate_bytes: u64, progress: impl Fn(BulkProgress), ) -> Result<PreseedResult, String>
Fetches every card’s art at the given variants, pinning as it goes.
Resumable by design: what is already on disk is skipped, so a cancelled
run picks up where it stopped. progress is called roughly every 25
cards and at the end, so a caller can render it however it likes.
Auto Trait Implementations§
impl !Freeze for ImageCache
impl !RefUnwindSafe for ImageCache
impl !UnwindSafe for ImageCache
impl Send for ImageCache
impl Sync for ImageCache
impl Unpin for ImageCache
impl UnsafeUnpin for ImageCache
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