pub struct HttpTileSource { /* private fields */ }Expand description
A TileSource that fetches raster tiles over HTTP.
Uses a URL template with {z}, {x}, {y} placeholders and an
optional TileDecoder for image formats.
See the module-level documentation for the full request lifecycle and error mapping.
Implementations§
Source§impl HttpTileSource
impl HttpTileSource
Sourcepub fn new(url_template: impl Into<String>, client: Box<dyn HttpClient>) -> Self
pub fn new(url_template: impl Into<String>, client: Box<dyn HttpClient>) -> Self
Create a new HTTP tile source without image decoding.
Response bodies are assumed to be raw RGBA8 256x256 pixel data.
For real tile providers (OSM, Mapbox, etc.) use
with_decoder instead.
Sourcepub fn with_decoder(
url_template: impl Into<String>,
client: Box<dyn HttpClient>,
decoder: Box<dyn TileDecoder>,
) -> Self
pub fn with_decoder( url_template: impl Into<String>, client: Box<dyn HttpClient>, decoder: Box<dyn TileDecoder>, ) -> Self
Create a new HTTP tile source with a TileDecoder for
decoding PNG / JPEG / WebP response bodies into RGBA8.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Add a default header that will be sent with every tile request.
Useful for API keys, User-Agent overrides, or custom
authentication tokens. Returns self for chaining.
§Example
let source = HttpTileSource::new(template, client)
.with_header("User-Agent", "rustial/0.1")
.with_header("Authorization", "Bearer my-token");Sourcepub fn tile_url(&self, id: &TileId) -> String
pub fn tile_url(&self, id: &TileId) -> String
Expand the URL template for a given tile ID.
Replaces {z}, {x}, {y} with the tile’s zoom, column, and
row respectively.
Sourcepub fn url_template(&self) -> &str
pub fn url_template(&self) -> &str
The URL template this source was constructed with.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
The number of requests currently in flight (awaiting HTTP response).