Inline print variables (#328)

* Inline format messages

* Cargo auto fixes
This commit is contained in:
Philip Kristoffersen
2023-02-02 21:33:42 +01:00
committed by GitHub
parent e92196e701
commit 27b429adcd
24 changed files with 61 additions and 72 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ impl<'a> CachedSearch<'a> {
pub fn save(&self) {
if let Err(err) = save_search_map(&self.search_map) {
eprintln!("Failed saving searchmap : {:?}", err);
eprintln!("Failed saving searchmap : {err:?}");
}
}
+6 -7
View File
@@ -105,7 +105,7 @@ pub async fn download_images_for_users<'b>(
.collect::<Vec<()>>()
.await;
let duration = start_time.elapsed();
println!("Finished getting images in: {:?}", duration);
println!("Finished getting images in: {duration:?}");
//Validate that the downloads where ok
for to_download in to_downloads {
@@ -277,7 +277,7 @@ async fn search_for_images_to_download<T: SearchSettings>(
to_download.extend(download_for_this_type);
}
Err(err) => eprintln!("Error getting images: {}", err),
Err(err) => eprintln!("Error getting images: {err}"),
}
}
}
@@ -308,7 +308,7 @@ async fn get_images_for_ids(
let image_search_result = client.get_images_for_ids(image_ids, &query_type).await;
image_search_result.map_err(|e| format!("Image search failed {:?}", e))
image_search_result.map_err(|e| format!("Image search failed {e:?}"))
}
const BIG_PICTURE_DIMS: [GridDimentions; 2] = [GridDimentions::D920x430, GridDimentions::D460x215];
@@ -374,7 +374,7 @@ async fn get_steam_image_url(game_id: usize, image_type: &ImageType) -> Option<S
return Some(url);
}
}
let steamgriddb_page_url = format!("https://www.steamgriddb.com/api/public/game/{}/", game_id);
let steamgriddb_page_url = format!("https://www.steamgriddb.com/api/public/game/{game_id}/");
let response = reqwest::get(steamgriddb_page_url).await;
if let Ok(response) = response {
let text_response = response.json::<PublicGameResponse>().await;
@@ -398,7 +398,7 @@ async fn get_steam_image_url(game_id: usize, image_type: &ImageType) -> Option<S
}
async fn get_steam_icon_url(game_id: usize) -> Option<String> {
let steamgriddb_page_url = format!("https://www.steamgriddb.com/api/public/game/{}/", game_id);
let steamgriddb_page_url = format!("https://www.steamgriddb.com/api/public/game/{game_id}/");
let response = reqwest::get(steamgriddb_page_url).await;
if let Ok(response) = response {
let text_response = response.json::<PublicGameResponse>().await;
@@ -423,8 +423,7 @@ async fn get_steam_icon_url(game_id: usize) -> Option<String> {
fn icon_url(steam_app_id: &str, icon_id: &str) -> String {
format!(
"https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/{}/{}.ico",
steam_app_id, icon_id
"https://cdn.cloudflare.steamstatic.com/steamcommunity/public/images/apps/{steam_app_id}/{icon_id}.ico"
)
}
+11 -16
View File
@@ -51,12 +51,12 @@ impl ImageType {
pub fn file_name_no_extension(&self, app_id: u32) -> String {
match self {
ImageType::Hero => format!("{}_hero", app_id),
ImageType::Grid => format!("{}p", app_id),
ImageType::WideGrid => format!("{}", app_id),
ImageType::Logo => format!("{}_logo", app_id),
ImageType::BigPicture => format!("{}_bigpicture", app_id),
ImageType::Icon => format!("{}-icon", app_id),
ImageType::Hero => format!("{app_id}_hero"),
ImageType::Grid => format!("{app_id}p"),
ImageType::WideGrid => format!("{app_id}"),
ImageType::Logo => format!("{app_id}_logo"),
ImageType::BigPicture => format!("{app_id}_bigpicture"),
ImageType::Icon => format!("{app_id}-icon"),
}
}
@@ -64,24 +64,19 @@ impl ImageType {
let steam_app_id = steam_app_id.as_ref();
match self {
ImageType::Hero => format!(
"https://cdn.cloudflare.steamstatic.com/steam/apps/{}/library_hero.jpg?t={}",
steam_app_id, mtime
"https://cdn.cloudflare.steamstatic.com/steam/apps/{steam_app_id}/library_hero.jpg?t={mtime}"
),
ImageType::Grid => format!(
"https://cdn.cloudflare.steamstatic.com/steam/apps/{}/library_600x900_2x.jpg?t={}",
steam_app_id, mtime
"https://cdn.cloudflare.steamstatic.com/steam/apps/{steam_app_id}/library_600x900_2x.jpg?t={mtime}"
),
ImageType::WideGrid => format!(
"https://cdn.cloudflare.steamstatic.com/steam/apps/{}/header.jpg?t={}",
steam_app_id, mtime
"https://cdn.cloudflare.steamstatic.com/steam/apps/{steam_app_id}/header.jpg?t={mtime}"
),
ImageType::Logo => format!(
"https://cdn.cloudflare.steamstatic.com/steam/apps/{}/logo.png?t={}",
steam_app_id, mtime
"https://cdn.cloudflare.steamstatic.com/steam/apps/{steam_app_id}/logo.png?t={mtime}"
),
ImageType::BigPicture => format!(
"https://cdn.cloudflare.steamstatic.com/steam/apps/{}/header.jpg?t={}",
steam_app_id, mtime
"https://cdn.cloudflare.steamstatic.com/steam/apps/{steam_app_id}/header.jpg?t={mtime}"
),
// This should not happen
_ => "".to_string(),