diff --git a/src/cgg_data_source.rs b/src/cgg_data_source.rs index 9340d4b..5780ce2 100644 --- a/src/cgg_data_source.rs +++ b/src/cgg_data_source.rs @@ -6,8 +6,8 @@ use std::collections::HashMap; use std::sync::Mutex; use crate::data_source::{DataSource, Stat}; -use crate::Champion; use crate::ChampInfo; +use crate::Champion; #[derive(Deserialize, Debug)] struct BuildResponse { @@ -104,7 +104,11 @@ impl DataSource for CGGDataSource { 0 } - fn get_champs_with_positions(&self, client: &ureq::Agent, _champion: &Champion) -> IndexMap> { + fn get_champs_with_positions( + &self, + client: &ureq::Agent, + _champion: &Champion, + ) -> IndexMap> { let req = client.get("https://champion.gg").call().unwrap(); let page = &req.into_string().unwrap(); diff --git a/src/data_source.rs b/src/data_source.rs index e5bbdb6..676f54f 100644 --- a/src/data_source.rs +++ b/src/data_source.rs @@ -44,7 +44,11 @@ pub trait DataSource { fn get_timeout(&self) -> u64; - fn get_champs_with_positions(&self, client: &ureq::Agent, champion: &Champion) -> IndexMap>; + fn get_champs_with_positions( + &self, + client: &ureq::Agent, + champion: &Champion, + ) -> IndexMap>; fn get_champ_data_with_win_pourcentage( &self, diff --git a/src/kb_data_source.rs b/src/kb_data_source.rs index cddb196..5acc76d 100644 --- a/src/kb_data_source.rs +++ b/src/kb_data_source.rs @@ -1,6 +1,6 @@ use crate::data_source::{Build, DataSource, Item, Stat}; -use crate::Champion as ChampionLoL; use crate::ChampInfo; +use crate::Champion as ChampionLoL; use crate::USER_AGENT_VALUE; use indexmap::IndexMap; use lazy_static::lazy_static; @@ -115,7 +115,9 @@ fn get_auth_token() -> Option { None => return None, }; bundle = (&bundle[(q_position + 1)..]).to_string(); - bundle.find('"').map(|position| (&bundle[..position]).to_string()) + bundle + .find('"') + .map(|position| (&bundle[..position]).to_string()) } impl KBDataSource { @@ -294,7 +296,11 @@ impl DataSource for KBDataSource { 300 } - fn get_champs_with_positions(&self, client: &ureq::Agent, _champion: &ChampionLoL) -> IndexMap> { + fn get_champs_with_positions( + &self, + client: &ureq::Agent, + _champion: &ChampionLoL, + ) -> IndexMap> { let mut champions = IndexMap::new(); let data: ChampionResponse = match self.get_champion_response(client) { Some(val) => val, @@ -375,7 +381,7 @@ mod tests { .build(); let datasource = KBDataSource::new(); let champion = ChampionLoL { - data: IndexMap::new() + data: IndexMap::new(), }; let champs_with_positions = datasource.get_champs_with_positions(&client, &champion); assert!(champs_with_positions.len() > 0); diff --git a/src/main.rs b/src/main.rs index ebd7cab..dae95f2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,14 +21,14 @@ use winreg::RegKey; mod cgg_data_source; mod data_source; mod kb_data_source; -mod pb_data_source; mod ms_data_source; +mod pb_data_source; use cgg_data_source::CGGDataSource; use data_source::DataSource; use kb_data_source::KBDataSource; -use pb_data_source::PBDataSource; use ms_data_source::MSDataSource; +use pb_data_source::PBDataSource; #[derive(Deserialize)] struct Realm { @@ -101,8 +101,12 @@ fn main() -> Result<(), Box> { .into_json()?; info!("LoL numbers of champs: {}", champion.data.len()); - let data_sources: [&'static (dyn DataSource + Sync + Send); 4] = - [&PBDataSource, &CGGDataSource, KBDataSource::new(), &MSDataSource]; + let data_sources: [&'static (dyn DataSource + Sync + Send); 4] = [ + &PBDataSource, + &CGGDataSource, + KBDataSource::new(), + &MSDataSource, + ]; data_sources.par_iter().for_each(|data_source| { let init = Instant::now(); execute_data_source(*data_source, &client, &champion, &lol_champs_dir); diff --git a/src/pb_data_source.rs b/src/pb_data_source.rs index 728c435..d64dc21 100644 --- a/src/pb_data_source.rs +++ b/src/pb_data_source.rs @@ -3,8 +3,8 @@ use serde_derive::Deserialize; use serde_json::{json, Value}; use crate::data_source::{DataSource, Stat}; -use crate::Champion as ChampionLoL; use crate::ChampInfo; +use crate::Champion as ChampionLoL; pub struct PBDataSource; @@ -27,7 +27,11 @@ impl DataSource for PBDataSource { 300 } - fn get_champs_with_positions(&self, client: &ureq::Agent, _champion: &ChampionLoL) -> IndexMap> { + fn get_champs_with_positions( + &self, + client: &ureq::Agent, + _champion: &ChampionLoL, + ) -> IndexMap> { let mut champs = IndexMap::new(); let page = client