Skip to main content

HttpTileSource

Struct HttpTileSource 

Source
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

Source

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.

Source

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.

Source

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");
Source

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.

Source

pub fn url_template(&self) -> &str

The URL template this source was constructed with.

Source

pub fn pending_count(&self) -> usize

The number of requests currently in flight (awaiting HTTP response).

Trait Implementations§

Source§

impl Debug for HttpTileSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TileSource for HttpTileSource

Source§

fn request(&self, id: TileId)

Start fetching a tile. Returns immediately. Read more
Source§

fn request_revalidate(&self, id: TileId, hint: RevalidationHint)

Start a conditional revalidation fetch for a stale tile. Read more
Source§

fn poll(&self) -> Vec<(TileId, Result<TileResponse, TileError>)>

Poll for completed tile fetches. Read more
Source§

fn cancel(&self, id: TileId)

Cancel a previously requested tile fetch. Read more
Source§

fn diagnostics(&self) -> Option<TileSourceDiagnostics>

Optional runtime diagnostics about the source fetch pipeline.
Source§

fn request_many(&self, ids: &[TileId])

Start fetching multiple tiles. Read more
Source§

fn request_revalidate_many(&self, ids: &[(TileId, RevalidationHint)])

Start conditional revalidation for multiple tiles. Read more
Source§

fn cancel_many(&self, ids: &[TileId])

Cancel multiple previously requested tile fetches. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.