pub trait TileCache: Send + Sync {
// Required methods
fn get(&self, key: TileKey) -> Option<Image>;
fn put(&self, key: TileKey, bytes: &[u8]) -> Result<(), CacheError>;
// Provided methods
fn contains(&self, key: TileKey) -> bool { ... }
fn get_bytes(&self, _key: TileKey) -> Option<Vec<u8>> { ... }
}Expand description
Local storage for downloaded tiles. Implementations decide whether
the backing is a slippy-map directory tree, an MBTiles SQLite db,
a single PMTiles archive, or an in-memory HashMap for tests.
Required Methods§
Provided Methods§
Sourcefn 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.
Sourcefn 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".