From 9459b6adb942e34df04ba2d6b1d7b6805ec3bb63 Mon Sep 17 00:00:00 2001 From: endernon Date: Thu, 2 Jan 2025 12:25:49 +0000 Subject: [PATCH] cargo fmt --- src/encode.rs | 29 +++++++++++++++++++---------- src/errorfr.rs | 4 +++- src/jsondl.rs | 13 ++++++------- src/jsonstruct.rs | 6 +++--- src/main.rs | 15 +++++---------- 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/encode.rs b/src/encode.rs index 91f6307..9a54ec4 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -1,7 +1,12 @@ -use std::collections::HashMap; -use idmangler_lib::{DataEncoder, EndData, IdentificationData, NameData, PowderData, RerollData, ShinyData, StartData, TypeData}; +use crate::jsonstruct::{ + FuncParams, Identificationer, ItemTypeDeser, Powder, Shinyjson, Shinystruct, +}; use idmangler_lib::types::{Element, ItemType, RollType, Stat}; -use crate::jsonstruct::{FuncParams, Identificationer, ItemTypeDeser, Powder, Shinyjson, Shinystruct}; +use idmangler_lib::{ + DataEncoder, EndData, IdentificationData, NameData, PowderData, RerollData, ShinyData, + StartData, TypeData, +}; +use std::collections::HashMap; pub fn encode_startdata(general_params: &mut FuncParams) { // ENCODE: StartData @@ -53,8 +58,8 @@ pub fn encode_ids( identifications: idvec, extended_encoding: true, } - .encode(general_params.fr_ver, general_params.fr_out) - .unwrap(); + .encode(general_params.fr_ver, general_params.fr_out) + .unwrap(); } pub fn encode_powder(general_params: &mut FuncParams, real_powders: Vec) { let mut powdervec = Vec::new(); @@ -89,8 +94,8 @@ pub fn encode_powder(general_params: &mut FuncParams, real_powders: Vec) powder_slots: powderlimitfr, powders: powdervec, } - .encode(general_params.fr_ver, general_params.fr_out) - .unwrap(); + .encode(general_params.fr_ver, general_params.fr_out) + .unwrap(); } pub fn encode_reroll(general_params: &mut FuncParams, rerollcount: u8) { if rerollcount != 0 { @@ -103,7 +108,11 @@ pub fn encode_reroll(general_params: &mut FuncParams, rerollcount: u8) { } } } -pub fn encode_shiny(general_params: &mut FuncParams, shiny: Shinyjson, json_shiny: Vec) { +pub fn encode_shiny( + general_params: &mut FuncParams, + shiny: Shinyjson, + json_shiny: Vec, +) { let mut realshinykey: u8; let _shinykey = &shiny.key; let shinyvalue = shiny.value; @@ -125,8 +134,8 @@ pub fn encode_shiny(general_params: &mut FuncParams, shiny: Shinyjson, json_shin id: realshinykey, val: shinyvalue, } - .encode(general_params.fr_ver, general_params.fr_out) - .unwrap(); + .encode(general_params.fr_ver, general_params.fr_out) + .unwrap(); } pub fn encode_enddata(general_params: &mut FuncParams) { // ENCODE: EndData diff --git a/src/errorfr.rs b/src/errorfr.rs index 986a741..fd864f6 100644 --- a/src/errorfr.rs +++ b/src/errorfr.rs @@ -44,6 +44,8 @@ pub enum Errorfr { JsonDlReqFileWriteFail, /// Name value was not found in json - #[error("Error 3.4: \"name\" field was not found in the json (required for Gear, Tome, Charm).")] + #[error( + "Error 3.4: \"name\" field was not found in the json (required for Gear, Tome, Charm)." + )] JsonNotFoundName, } diff --git a/src/jsondl.rs b/src/jsondl.rs index bdc16bf..f73bfd1 100644 --- a/src/jsondl.rs +++ b/src/jsondl.rs @@ -1,10 +1,9 @@ -use std::collections::HashMap; -use std::fs; -use serde::Deserialize; use crate::dl_json; use crate::errorfr::Errorfr; -use crate::jsonstruct::{Shinystruct}; - +use crate::jsonstruct::Shinystruct; +use serde::Deserialize; +use std::collections::HashMap; +use std::fs; pub fn load_idkeys(executable_path: &str) -> Result, Errorfr> { // id_keys.json @@ -12,7 +11,7 @@ pub fn load_idkeys(executable_path: &str) -> Result, Errorfr &mut fs::File::open(executable_path.to_owned() + "/id_keys.json") .map_err(|_| Errorfr::IDMapJsonMissing)?, ) - .map_err(|_| Errorfr::IDMapJsonCorrupt) + .map_err(|_| Errorfr::IDMapJsonCorrupt) } pub fn load_shinystats(executable_path: &str) -> Result, Errorfr> { // shiny_stats.json @@ -20,7 +19,7 @@ pub fn load_shinystats(executable_path: &str) -> Result, Errorf &mut fs::File::open(executable_path.to_owned() + "/shiny_stats.json") .map_err(|_| Errorfr::ShinyJsonMissing)?, ) - .map_err(|_| Errorfr::ShinyJsonCorrupt) + .map_err(|_| Errorfr::ShinyJsonCorrupt) } pub fn dl_json_fr(dlvalue: &String, executable_path: &str) { let jsons = DownloadJsons::from(dlvalue.clone()); diff --git a/src/jsonstruct.rs b/src/jsonstruct.rs index b62d9b7..b1fb565 100644 --- a/src/jsonstruct.rs +++ b/src/jsonstruct.rs @@ -1,7 +1,7 @@ -use std::fs; +use crate::errorfr::Errorfr; use idmangler_lib::types::{ItemType, TransformVersion}; use serde::Deserialize; -use crate::errorfr::Errorfr; +use std::fs; // structs for the json parsing #[derive(Deserialize)] @@ -69,4 +69,4 @@ impl From for ItemType { 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 9f80d84..8af70d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,17 @@ #![allow(clippy::single_match)] -use idmangler_lib::{ - encoding::encode_string, - types::TransformVersion, -}; +use idmangler_lib::{encoding::encode_string, types::TransformVersion}; use std::{collections::HashMap, env, fs, io, path::PathBuf}; -mod jsonstruct; -mod errorfr; mod encode; +mod errorfr; mod jsondl; -use crate::jsonstruct::*; -use crate::errorfr::Errorfr; +mod jsonstruct; use crate::encode::*; +use crate::errorfr::Errorfr; use crate::jsondl::*; +use crate::jsonstruct::*; use clap::Parser; use reqwest::Url; @@ -185,5 +182,3 @@ fn cook( Ok(()) } - -