From 48393b209396db9ddd44251b2bb445d3ad7533fb Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 25 May 2023 17:23:52 +0200 Subject: changed a whole lot og references, fuck rust --- src/commands/io.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/commands/io.rs') diff --git a/src/commands/io.rs b/src/commands/io.rs index 2a26f1d..43e642a 100644 --- a/src/commands/io.rs +++ b/src/commands/io.rs @@ -21,9 +21,9 @@ struct ExportVersion { } impl ExportVersion { - fn from(config: Cfg, list_id: &str, mod_id: &str) -> MLE { + fn from(config: &Cfg, list_id: &str, mod_id: &str) -> MLE { Ok(Self { - version: userlist_get_current_version(config.clone(), list_id, mod_id)?, + version: userlist_get_current_version(config, list_id, mod_id)?, set: userlist_get_set_version(config, list_id, mod_id)? }) } @@ -39,18 +39,18 @@ struct ExportList { } impl ExportList { - pub fn from(config: Cfg, list_id: String, download: bool) -> MLE { - let list = lists_get(config.clone(), String::from(&list_id))?; + pub fn from(config: &Cfg, list_id: String, download: bool) -> MLE { + let list = lists_get(config, String::from(&list_id))?; let mut dl_folder = None; if download { dl_folder = Some(list.download_folder) }; - let mods = userlist_get_all_ids(config.clone(), &list_id)?; + let mods = userlist_get_all_ids(config, &list_id)?; let mut versions = vec![]; for m in mods { - versions.push(ExportVersion::from(config.clone(), &list_id, &m)?) + versions.push(ExportVersion::from(config, &list_id, &m)?) } Ok(Self { @@ -63,16 +63,16 @@ impl ExportList { } } -pub fn export(config: Cfg, list: Option) -> MLE<()> { +pub fn export(config: &Cfg, list: Option) -> MLE<()> { let mut list_ids: Vec = vec![]; if list.is_none() { - list_ids = lists_get_all_ids(config.clone())?; + list_ids = lists_get_all_ids(config)?; } else { - list_ids.push(lists_get(config.clone(), list.unwrap())?.id); + list_ids.push(lists_get(config, list.unwrap())?.id); } let mut lists: Vec = vec![]; for list_id in list_ids { - lists.push(ExportList::from(config.clone(), list_id, true)?); + lists.push(ExportList::from(config, list_id, true)?); } let toml = toml::to_string(&Export { lists })?; @@ -85,7 +85,7 @@ pub fn export(config: Cfg, list: Option) -> MLE<()> { Ok(()) } -pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE<()> { +pub async fn import(config: &Cfg, file_str: String, direct_download: bool) -> MLE<()> { let mut file = File::open(file_str)?; let mut content = String::new(); file.read_to_string(&mut content)?; @@ -99,18 +99,18 @@ pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), }; lists_insert( - config.clone(), - list.id.clone(), - list.mc_version.clone(), - list.modloader.clone(), - String::from(&list.download_folder), + config, + &list.id, + &list.mc_version, + &list.modloader, + &list.download_folder, )?; let mut ver_ids = vec![]; for id in exportlist.versions { ver_ids.push(AddMod { id: IDSelector::VersionID(id.version), set_version: id.set} ); } - mod_add(config.clone(), ver_ids, list, direct_download).await?; + mod_add(config, ver_ids, list, direct_download).await?; } Ok(()) } -- cgit v1.2.3