From 69d25039f93942ed2d523e97be9dbda6162dfc30 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Tue, 27 Feb 2024 14:01:20 +0100 Subject: [PATCH] fixed formatting mistakes --- server/main-api/src/maps/fetch_tile.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/server/main-api/src/maps/fetch_tile.rs b/server/main-api/src/maps/fetch_tile.rs index 24b7c74aa..473ff1ef4 100644 --- a/server/main-api/src/maps/fetch_tile.rs +++ b/server/main-api/src/maps/fetch_tile.rs @@ -5,8 +5,8 @@ use std::time::Duration; use cached::proc_macro::io_cached; use log::{error, warn}; -use crate::BoxedError; use crate::maps::overlay_map::OverlayMapTask; +use crate::BoxedError; #[derive(Hash, Debug, Copy, Clone)] struct TileLocation { @@ -25,7 +25,6 @@ impl Display for TileLocation { } } - #[derive(Debug)] pub(crate) struct FetchTileTask { location: TileLocation, @@ -91,7 +90,6 @@ impl FetchTileTask { } } - // type and create are specified, because a custom conversion is needed pub async fn fulfill(self) -> Option<((u32, u32), image::DynamicImage)> { let raw_tile = download_map_image(self.location).await; @@ -102,7 +100,7 @@ impl FetchTileTask { error!("Error while parsing image: {e:#?} for {self:?}"); None } - } + }, Err(e) => { error!("could not fulfill {self:?} because {e}"); None @@ -113,7 +111,12 @@ impl FetchTileTask { #[io_cached(disk = true, map_error = r##"|e| format!("{e:?}")"##)] async fn download_map_image(location: TileLocation) -> Result, BoxedError> { - let url = format!("https://nav.tum.de/maps/styles/osm-liberty/{z}/{x}/{y}@2x.png", x = location.x, y = location.y, z = location.z); + let url = format!( + "https://nav.tum.de/maps/styles/osm-liberty/{z}/{x}/{y}@2x.png", + x = location.x, + y = location.y, + z = location.z + ); for i in 1..5 { let res = reqwest::get(&url).await?.bytes().await?; // wait with exponential backoff @@ -122,9 +125,12 @@ async fn download_map_image(location: TileLocation) -> Result, BoxedErro } else { let wait_time_ms = 1.5_f32.powi(i).round() as u64; let wait_time = Duration::from_millis(wait_time_ms); - warn!("retrying tileserver-request in {wait_time:?} because it is only {request_len}B", request_len=res.len()); + warn!( + "retrying tileserver-request in {wait_time:?} because it is only {request_len}B", + request_len = res.len() + ); tokio::time::sleep(wait_time).await; } - }; + } Err(format!("Got only short Responses from {url}").into()) -} \ No newline at end of file +}