From caba0e459df4fde13a5e2e1b4d4d462efb821d78 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Sat, 25 Sep 2021 09:45:38 +0200 Subject: [PATCH] Refactor cached search into steamgriddb mod --- src/main.rs | 20 +------------------- src/{ => steamgriddb}/cached_search.rs | 0 src/steamgriddb/image_type.rs | 16 ++++++++++++++++ src/steamgriddb/mod.rs | 7 ++++++- 4 files changed, 23 insertions(+), 20 deletions(-) rename src/{ => steamgriddb}/cached_search.rs (100%) create mode 100644 src/steamgriddb/image_type.rs diff --git a/src/main.rs b/src/main.rs index a3dd97a..7aa5061 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use crate::steamgriddb::{CachedSearch, ImageType}; use std::{ collections::HashMap, env::{self}, @@ -7,7 +8,6 @@ use std::{ ops::Deref, path::Path, }; -mod cached_search; mod egs; mod legendary; mod platform; @@ -28,8 +28,6 @@ use steam_shortcuts_util::{ }; use steamgriddb_api::{search::SearchResult, Client}; -use crate::cached_search::CachedSearch; - #[tokio::main] async fn main() -> Result<(), Box> { let settings = Settings::new()?; @@ -146,22 +144,6 @@ fn save_shortcuts(shortcuts: &Vec, path: &Path) { 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(platform: &P, current_shortcuts: &mut Vec) where P: Platform, diff --git a/src/cached_search.rs b/src/steamgriddb/cached_search.rs similarity index 100% rename from src/cached_search.rs rename to src/steamgriddb/cached_search.rs diff --git a/src/steamgriddb/image_type.rs b/src/steamgriddb/image_type.rs new file mode 100644 index 0000000..470a678 --- /dev/null +++ b/src/steamgriddb/image_type.rs @@ -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), + } + } +} \ No newline at end of file diff --git a/src/steamgriddb/mod.rs b/src/steamgriddb/mod.rs index abfb15a..8d92d20 100644 --- a/src/steamgriddb/mod.rs +++ b/src/steamgriddb/mod.rs @@ -1,2 +1,7 @@ mod settings; -pub use settings::SteamGridDbSettings; \ No newline at end of file +mod image_type; +mod cached_search; + +pub use image_type::ImageType; +pub use settings::SteamGridDbSettings; +pub use cached_search::CachedSearch; \ No newline at end of file