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/db.rs | 70 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/db.rs') diff --git a/src/db.rs b/src/db.rs index dde00ab..3409298 100644 --- a/src/db.rs +++ b/src/db.rs @@ -9,7 +9,7 @@ use crate::{ }; //MODS -pub fn mods_insert(config: Cfg, id: &str, slug: &str, name: &str) -> MLE<()> { +pub fn mods_insert(config: &Cfg, id: &str, slug: &str, name: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -21,7 +21,7 @@ pub fn mods_insert(config: Cfg, id: &str, slug: &str, name: &str) -> MLE<()> { Ok(()) } -pub fn mods_get_all_ids(config: Cfg) -> Result, Box> { +pub fn mods_get_all_ids(config: &Cfg) -> Result, Box> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -120,7 +120,7 @@ pub fn mods_get_info(config: &Cfg, id: &str) -> MLE { } } -pub fn mods_remove(config: Cfg, id: String) -> MLE<()> { +pub fn mods_remove(config: &Cfg, id: String) -> MLE<()> { println!("Removing mod {} from database", id); let data = format!("{}/data.db", config.data); @@ -137,7 +137,7 @@ pub struct DBModlistVersions { pub versions: String, } -pub fn mods_get_versions(config: Cfg, mods: Vec) -> MLE> { +pub fn mods_get_versions(config: &Cfg, mods: Vec) -> MLE> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -186,7 +186,7 @@ pub fn mods_get_versions(config: Cfg, mods: Vec) -> MLE MLE> { +pub fn userlist_get_all_ids(config: &Cfg, list_id: &str) -> MLE> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -239,7 +239,7 @@ pub fn userlist_get_all_ids(config: Cfg, list_id: &str) -> MLE> { } } -pub fn userlist_remove(config: Cfg, list_id: &str, mod_id: &str) -> MLE<()> { +pub fn userlist_remove(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -251,7 +251,7 @@ pub fn userlist_remove(config: Cfg, list_id: &str, mod_id: &str) -> MLE<()> { } pub fn userlist_get_applicable_versions( - config: Cfg, + config: &Cfg, list_id: String, mod_id: String, ) -> MLE { @@ -279,7 +279,7 @@ pub fn userlist_get_applicable_versions( } pub fn userlist_get_all_applicable_versions_with_mods( - config: Cfg, + config: &Cfg, list_id: String, ) -> MLE> { let data = format!("{}/data.db", config.data); @@ -307,7 +307,7 @@ pub fn userlist_get_all_applicable_versions_with_mods( Ok(versions) } -pub fn userlist_get_current_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE { +pub fn userlist_get_current_version(config: &Cfg, list_id: &str, mod_id: &str) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -327,7 +327,7 @@ pub fn userlist_get_current_version(config: Cfg, list_id: &str, mod_id: &str) -> } pub fn userlist_get_all_current_version_ids( - config: Cfg, + config: &Cfg, list_id: String, ) -> MLE> { let data = format!("{}/data.db", config.data); @@ -353,7 +353,7 @@ pub fn userlist_get_all_current_version_ids( } pub fn userlist_get_all_current_versions_with_mods( - config: Cfg, + config: &Cfg, list_id: String, ) -> Result, Box> { let data = format!("{}/data.db", config.data); @@ -384,7 +384,7 @@ pub fn userlist_get_all_current_versions_with_mods( Ok(versions) } -pub fn userlist_get_set_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE { +pub fn userlist_get_set_version(config: &Cfg, list_id: &str, mod_id: &str) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -401,7 +401,7 @@ pub fn userlist_get_set_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE } pub fn userlist_change_versions( - config: Cfg, + config: &Cfg, list_id: String, current_version: String, versions: String, @@ -416,7 +416,7 @@ pub fn userlist_change_versions( } pub fn userlist_add_disabled_versions( - config: Cfg, + config: &Cfg, list_id: String, disabled_version: String, mod_id: String, @@ -442,7 +442,7 @@ pub fn userlist_add_disabled_versions( Ok(()) } -pub fn userlist_get_disabled_versions(config: Cfg, list_id: String, mod_id: String) -> MLE { +pub fn userlist_get_disabled_versions(config: &Cfg, list_id: String, mod_id: String) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -462,7 +462,7 @@ pub fn userlist_get_disabled_versions(config: Cfg, list_id: String, mod_id: Stri } pub fn userlist_get_all_downloads( - config: Cfg, + config: &Cfg, list_id: String, ) -> Result, Box> { let data = format!("{}/data.db", config.data); @@ -492,11 +492,11 @@ pub fn userlist_get_all_downloads( //lists ///Inserts into lists table and creates new table pub fn lists_insert( - config: Cfg, - id: String, - mc_version: String, - mod_loader: Modloader, - download_folder: String, + config: &Cfg, + id: &str, + mc_version: &str, + mod_loader: &Modloader, + download_folder: &str, ) -> MLE<()> { println!("Creating list {}", id); @@ -506,9 +506,9 @@ pub fn lists_insert( connection.execute( "INSERT INTO lists VALUES (?1, ?2, ?3, ?4)", [ - id.clone(), + id, mc_version, - mod_loader.to_string(), + &mod_loader.to_string(), download_folder, ], )?; @@ -517,7 +517,7 @@ pub fn lists_insert( Ok(()) } -pub fn lists_remove(config: Cfg, id: String) -> MLE<()> { +pub fn lists_remove(config: &Cfg, id: String) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -526,7 +526,7 @@ pub fn lists_remove(config: Cfg, id: String) -> MLE<()> { Ok(()) } -pub fn lists_get(config: Cfg, list_id: String) -> MLE { +pub fn lists_get(config: &Cfg, list_id: String) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -564,7 +564,7 @@ pub fn lists_get(config: Cfg, list_id: String) -> MLE { Ok(list) } -pub fn lists_version(config: Cfg, list_id: &str, version: &str) -> MLE<()> { +pub fn lists_version(config: &Cfg, list_id: &str, version: &str) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -575,7 +575,7 @@ pub fn lists_version(config: Cfg, list_id: &str, version: &str) -> MLE<()> { Ok(()) } -pub fn lists_get_all_ids(config: Cfg) -> MLE> { +pub fn lists_get_all_ids(config: &Cfg) -> MLE> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -594,7 +594,7 @@ pub fn lists_get_all_ids(config: Cfg) -> MLE> { } //config -pub fn config_change_current_list(config: Cfg, id: String) -> MLE<()> { +pub fn config_change_current_list(config: &Cfg, id: String) -> MLE<()> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -605,7 +605,7 @@ pub fn config_change_current_list(config: Cfg, id: String) -> MLE<()> { Ok(()) } -pub fn config_get_current_list(config: Cfg) -> MLE { +pub fn config_get_current_list(config: &Cfg) -> MLE { let data = format!("{}/data.db", config.data); let connection = Connection::open(data).unwrap(); @@ -626,7 +626,7 @@ pub fn config_get_current_list(config: Cfg) -> MLE { //SETUP(UPDATES) pub fn s_userlist_update_download( - config: Cfg, + config: &Cfg, list_id: String, mod_id: String, link: String, @@ -645,7 +645,7 @@ pub fn s_userlist_update_download( Ok(()) } -pub fn s_config_create_version(config: Cfg) -> Result<(), Box> { +pub fn s_config_create_version(config: &Cfg) -> Result<(), Box> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -656,7 +656,7 @@ pub fn s_config_create_version(config: Cfg) -> Result<(), Box Result<(), Box> { +pub fn s_config_update_version(config: &Cfg, ver: String) -> Result<(), Box> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -667,7 +667,7 @@ pub fn s_config_update_version(config: Cfg, ver: String) -> Result<(), Box Result> { +pub fn s_config_get_version(config: &Cfg) -> Result> { let data = format!("{}/data.db", config.data); let connection = Connection::open(data)?; @@ -689,7 +689,7 @@ pub fn s_config_get_version(config: Cfg) -> Result