pub struct LayeredTileCache { /* private fields */ }Expand description
Read-through composite cache. get / contains try each layer
in order until one hits; put only writes to the first layer
(which must be writable). Use to overlay a writable user cache
over a read-only bundled cache: the bundled tiles serve instantly,
new fetches accumulate in the user cache without polluting the
bundle.
Implementations§
Trait Implementations§
Source§impl TileCache for LayeredTileCache
impl TileCache for LayeredTileCache
Source§fn get(&self, key: TileKey) -> Option<Image>
fn get(&self, key: TileKey) -> Option<Image>
Look up the cached tile, decoded as a
slint::Image. Returns
None if the tile isn’t cached (or if its bytes failed to
decode). Implementations should be cheap on the miss path.Source§fn put(&self, key: TileKey, bytes: &[u8]) -> Result<(), CacheError>
fn put(&self, key: TileKey, bytes: &[u8]) -> Result<(), CacheError>
Store raw bytes (typically a PNG payload exactly as the source
served it — the cache is encoding-agnostic). Errors here are
returned but a fetching source will typically just log and
keep going.
Source§fn contains(&self, key: TileKey) -> bool
fn contains(&self, key: TileKey) -> bool
Quick existence check that avoids the decode cost of
get.
Default implementation falls back to get(key).is_some() —
override on backends where existence is cheaper to test.Source§fn get_bytes(&self, key: TileKey) -> Option<Vec<u8>>
fn get_bytes(&self, key: TileKey) -> Option<Vec<u8>>
Read the raw bytes for a tile, if cached. Used by sources that
want to do their own (off-UI-thread) decoding rather than the
in-thread decode that
get performs. Default returns None —
backends that store raw bytes (FileTileCache) should override.Auto Trait Implementations§
impl !RefUnwindSafe for LayeredTileCache
impl !UnwindSafe for LayeredTileCache
impl Freeze for LayeredTileCache
impl Send for LayeredTileCache
impl Sync for LayeredTileCache
impl Unpin for LayeredTileCache
impl UnsafeUnpin for LayeredTileCache
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