Skip to main content

TileSource

Trait TileSource 

Source
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§

Source

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§

Source

fn tile_size(&self) -> u32

Tile edge length in pixels. Default 256 matches every common slippy-map source; vector / retina sources may emit 512.

Source

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

Source

fn min_zoom(&self) -> u8

Inclusive minimum zoom level. Default 0 (whole world in one tile).

Source

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

Implementations on Foreign Types§

Source§

impl<T: TileSource + ?Sized> TileSource for Box<T>

Source§

fn tile(&self, key: TileKey) -> Option<Image>

Source§

fn tile_size(&self) -> u32

Source§

fn min_zoom(&self) -> u8

Source§

fn max_zoom(&self) -> u8

Source§

fn cancel_all_except(&self, keep: &HashSet<TileKey>)

Implementors§