Skip to content

Commit a673079

Browse files
committed
Make tile loader public
1 parent db877ce commit a673079

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ pub mod map_event;
99
/// The map widget.
1010
pub mod mapvas_egui;
1111
/// Map tile functionality.
12-
mod tile_loader;
12+
pub mod tile_loader;
1313
/// Tile rendering abstraction for raster and vector tiles.
1414
pub mod tile_renderer;

src/map/tile_loader.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl Ord for PrioritizedTileRequest {
7676
}
7777

7878
/// The interface the cached and non-cached tile loader.
79+
#[allow(async_fn_in_trait)]
7980
pub trait TileLoader {
8081
/// Tries to fetch the tile data asyncroneously.
8182
async fn tile_data(&self, tile: &Tile, source: TileSource) -> Result<TileData, TileLoaderError>;
@@ -462,18 +463,22 @@ pub struct CachedTileLoader {
462463
}
463464

464465
impl CachedTileLoader {
466+
#[must_use]
465467
pub fn name(&self) -> &str {
466468
self.loader.name()
467469
}
468470

471+
#[must_use]
469472
pub fn tile_type(&self) -> TileType {
470473
self.format
471474
}
472475

476+
#[must_use]
473477
pub fn max_zoom(&self) -> u8 {
474478
self.max_zoom
475479
}
476480

481+
#[must_use]
477482
pub fn tiles_downloading(&self) -> usize {
478483
self
479484
.loader
@@ -484,6 +489,7 @@ impl CachedTileLoader {
484489
.len()
485490
}
486491

492+
#[must_use]
487493
pub fn tiles_queued(&self) -> usize {
488494
self
489495
.loader
@@ -527,6 +533,12 @@ impl CachedTileLoader {
527533
}
528534
}
529535

536+
/// Reads tile data from the local cache without triggering a network download.
537+
///
538+
/// # Errors
539+
///
540+
/// Returns [`TileLoaderError::TileNotAvailable`] if the tile is not present in
541+
/// the cache, or an I/O error if reading the cached file fails.
530542
pub async fn get_from_cache(
531543
&self,
532544
tile: &Tile,

0 commit comments

Comments
 (0)