pub trait TileSource: Send + Sync {
// Required method
fn tile(&self, key: TileKey) -> Option<Image>;
// Provided methods
fn tile_size(&self) -> u32 { ... }
fn max_zoom(&self) -> u8 { ... }
fn min_zoom(&self) -> u8 { ... }
fn cancel_all_except(&self, _keep: &HashSet<TileKey>) { ... }
}Expand description
An on-disk or in-memory tile source. Adapters implement this.
Required Methods§
Sourcefn tile(&self, key: TileKey) -> Option<Image>
fn tile(&self, key: TileKey) -> Option<Image>
Return the tile at (x, y, z), or None if it isn’t available
(out of bounds, missing from disk, not yet downloaded, …).
Implementations must not block the caller for long — kick off
any expensive fetch on a background task and return None until
the result lands in your cache.
Provided Methods§
Sourcefn tile_size(&self) -> u32
fn tile_size(&self) -> u32
Tile edge length in pixels. Default 256 matches every common slippy-map source; vector / retina sources may emit 512.
Sourcefn max_zoom(&self) -> u8
fn max_zoom(&self) -> u8
Inclusive maximum zoom level this source serves. Used by the controller to clamp user-initiated zoom. Default is “any zoom up to Web Mercator’s practical ceiling”.
Sourcefn cancel_all_except(&self, _keep: &HashSet<TileKey>)
fn cancel_all_except(&self, _keep: &HashSet<TileKey>)
Drop any queued (but not yet started) work for keys NOT in
keep. Default no-op — synchronous sources have no in-flight
work to cancel. Fetching / decoding implementations should
override this so rapidly-panning consumers don’t accumulate
off-screen requests that waste bandwidth on tiles nobody will
see by the time they arrive.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".