Refactor cached search into steamgriddb mod

This commit is contained in:
Philip Kristoffersen
2021-09-25 09:45:38 +02:00
parent e449bd31e4
commit caba0e459d
4 changed files with 23 additions and 20 deletions
+1 -19
View File
@@ -1,3 +1,4 @@
use crate::steamgriddb::{CachedSearch, ImageType};
use std::{ use std::{
collections::HashMap, collections::HashMap,
env::{self}, env::{self},
@@ -7,7 +8,6 @@ use std::{
ops::Deref, ops::Deref,
path::Path, path::Path,
}; };
mod cached_search;
mod egs; mod egs;
mod legendary; mod legendary;
mod platform; mod platform;
@@ -28,8 +28,6 @@ use steam_shortcuts_util::{
}; };
use steamgriddb_api::{search::SearchResult, Client}; use steamgriddb_api::{search::SearchResult, Client};
use crate::cached_search::CachedSearch;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> { async fn main() -> Result<(), Box<dyn Error>> {
let settings = Settings::new()?; let settings = Settings::new()?;
@@ -146,22 +144,6 @@ fn save_shortcuts(shortcuts: &Vec<Shortcut>, path: &Path) {
file.write(new_content.as_slice()).unwrap(); file.write(new_content.as_slice()).unwrap();
} }
pub enum ImageType {
Hero,
Grid,
Logo,
}
impl ImageType {
pub fn file_name(&self, app_id: u32) -> String {
match self {
ImageType::Hero => format!("{}_hero.png", app_id),
ImageType::Grid => format!("{}p.png", app_id),
ImageType::Logo => format!("{}_logo.png", app_id),
}
}
}
fn update_platform_shortcuts<P, T, E>(platform: &P, current_shortcuts: &mut Vec<ShortcutOwned>) fn update_platform_shortcuts<P, T, E>(platform: &P, current_shortcuts: &mut Vec<ShortcutOwned>)
where where
P: Platform<T, E>, P: Platform<T, E>,
+16
View File
@@ -0,0 +1,16 @@
pub enum ImageType {
Hero,
Grid,
Logo,
}
impl ImageType {
pub fn file_name(&self, app_id: u32) -> String {
match self {
ImageType::Hero => format!("{}_hero.png", app_id),
ImageType::Grid => format!("{}p.png", app_id),
ImageType::Logo => format!("{}_logo.png", app_id),
}
}
}
+6 -1
View File
@@ -1,2 +1,7 @@
mod settings; mod settings;
pub use settings::SteamGridDbSettings; mod image_type;
mod cached_search;
pub use image_type::ImageType;
pub use settings::SteamGridDbSettings;
pub use cached_search::CachedSearch;