diff --git a/src/jsondl.rs b/src/jsondl.rs index 8084c0d..bdc16bf 100644 --- a/src/jsondl.rs +++ b/src/jsondl.rs @@ -1,13 +1,11 @@ use std::collections::HashMap; use std::fs; +use serde::Deserialize; use crate::dl_json; use crate::errorfr::Errorfr; -use crate::jsonstruct::{DownloadJsons, Jsonconfig, Shinystruct}; +use crate::jsonstruct::{Shinystruct}; + -pub fn load_jsonconfig(path: &String) -> Result { - serde_json5::from_reader(&mut fs::File::open(path).map_err(|_| Errorfr::ItemJsonMissing)?) - .map_err(Errorfr::ItemJsonCorrupt) -} pub fn load_idkeys(executable_path: &str) -> Result, Errorfr> { // id_keys.json serde_json5::from_reader( @@ -45,4 +43,39 @@ pub fn dl_json_fr(dlvalue: &String, executable_path: &str) { println!("{} Filename: {}", e, dlvalue) } } -} \ No newline at end of file +} + +// stuff for the bit for downloading data jsons for ease of use +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug, Deserialize)] +pub enum DownloadJsons { + None, + IdKeys, + ShinyStats, + All, +} +impl From for DownloadJsons { + fn from(value: String) -> Self { + match value.to_lowercase().as_str().trim() { + "none" => { + println!("download NONE"); + DownloadJsons::None + } + "id_keys" | "idkeys" | "idkeys.json" | "id_keys.json" => { + println!("download ID_KEYS"); + DownloadJsons::IdKeys + } + "shiny_stats" | "shinystats" | "shiny_stats.json" | "shinystats.json" => { + println!("download SHINY_STATS"); + DownloadJsons::ShinyStats + } + "all" | "everything" | "both" => { + println!("download BOTH"); + DownloadJsons::All + } + _ => { + println!("Could not understand what Jsons to download, sorry."); + DownloadJsons::None + } + } + } +} diff --git a/src/jsonstruct.rs b/src/jsonstruct.rs index 5bb2475..b62d9b7 100644 --- a/src/jsonstruct.rs +++ b/src/jsonstruct.rs @@ -1,5 +1,8 @@ +use std::fs; use idmangler_lib::types::{ItemType, TransformVersion}; use serde::Deserialize; +use crate::errorfr::Errorfr; + // structs for the json parsing #[derive(Deserialize)] pub struct Powder { @@ -63,37 +66,7 @@ impl From for ItemType { } } -// stuff for the bit for downloading data jsons for ease of use -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug, Deserialize)] -pub enum DownloadJsons { - None, - IdKeys, - ShinyStats, - All, -} -impl From for DownloadJsons { - fn from(value: String) -> Self { - match value.to_lowercase().as_str().trim() { - "none" => { - println!("download NONE"); - DownloadJsons::None - } - "id_keys" | "idkeys" | "idkeys.json" | "id_keys.json" => { - println!("download ID_KEYS"); - DownloadJsons::IdKeys - } - "shiny_stats" | "shinystats" | "shiny_stats.json" | "shinystats.json" => { - println!("download SHINY_STATS"); - DownloadJsons::ShinyStats - } - "all" | "everything" | "both" => { - println!("download BOTH"); - DownloadJsons::All - } - _ => { - println!("Could not understand what Jsons to download, sorry."); - DownloadJsons::None - } - } - } -} +pub fn load_jsonconfig(path: &String) -> Result { + serde_json5::from_reader(&mut fs::File::open(path).map_err(|_| Errorfr::ItemJsonMissing)?) + .map_err(Errorfr::ItemJsonCorrupt) +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 725c840..9f80d84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use idmangler_lib::{ encoding::encode_string, types::TransformVersion, - DataEncoder }; use std::{collections::HashMap, env, fs, io, path::PathBuf};