Skip to main content

FileTileCache

Struct FileTileCache 

Source
pub struct FileTileCache { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl FileTileCache

Source

pub fn new(root: impl Into<PathBuf>) -> Self

Source

pub fn with_extension(self, ext: impl Into<String>) -> Self

Override the tile file extension (default "png").

Source

pub fn path_for(&self, key: TileKey) -> PathBuf

Absolute on-disk path for the given tile.

Source

pub fn root(&self) -> &Path

Filesystem root this cache writes under.

Trait Implementations§

Source§

impl TileCache for FileTileCache

Source§

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

Look up the cached tile, decoded as a slint::Image. Returns None if the tile isn’t cached (or if its bytes failed to decode). Implementations should be cheap on the miss path.
Source§

fn put(&self, key: TileKey, bytes: &[u8]) -> Result<(), CacheError>

Store raw bytes (typically a PNG payload exactly as the source served it — the cache is encoding-agnostic). Errors here are returned but a fetching source will typically just log and keep going.
Source§

fn contains(&self, key: TileKey) -> bool

Quick existence check that avoids the decode cost of get. Default implementation falls back to get(key).is_some() — override on backends where existence is cheaper to test.
Source§

fn get_bytes(&self, key: TileKey) -> Option<Vec<u8>>

Read the raw bytes for a tile, if cached. Used by sources that want to do their own (off-UI-thread) decoding rather than the in-thread decode that get performs. Default returns None — backends that store raw bytes (FileTileCache) should override.

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.