Skip to main content

Module cache

Module cache 

Source
Expand description

TileCache — abstract local storage for tiles.

Every “fetching” tile source ([crate::sources::OsmTileSource] is the only one shipped today) writes through a TileCache rather than dealing with the filesystem / SQLite / whatever directly. That keeps the storage backend swappable: an embedded app can ship FileTileCache writing under the OS cache dir; a desktop app might prefer a single-file format (MBTiles, PMTiles); a test can use a Vec in memory.

FileTileCache is the one concrete implementation right now and is what backs the bundled sample-tiles/ directory.

Structs§

FileTileCache
Stores tiles in a slippy-map directory tree on disk ({root}/{z}/{x}/{y}.{ext}). Compatible with every common tile bundle layout (the OSM standard, MapTiler exports, Mapbox tile downloads). The bundled sample-tiles/ is one of these.
LayeredTileCache
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.

Enums§

CacheError
Error returned by TileCache::put.

Traits§

TileCache
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.