summaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-01-19 18:37:42 +0100
committerfxqnlr <[email protected]>2023-01-19 18:37:42 +0100
commitf7a6d2e9c67c1fdf8fc17fa0461a201fd2720537 (patch)
tree21d0c7356b55e9b45517fd9ca874dd3270b6bc3a /src/db.rs
parentbe9f74f4fb82b25abd99f7024e0f5eea2691f34f (diff)
downloadmodlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.tar
modlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.tar.gz
modlist-f7a6d2e9c67c1fdf8fc17fa0461a201fd2720537.zip
input mostly inplemented, mods missing
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/db.rs b/src/db.rs
index 06c2459..119b2a5 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -177,7 +177,7 @@ pub fn userlist_get_all_ids(config: Cfg, list_id: String) -> MLE<Vec<String>> {
177} 177}
178 178
179 179
180pub fn userlist_remove(config: Cfg, list_id: String, mod_id: String) -> Result<(), Box<dyn std::error::Error>> { 180pub fn userlist_remove(config: Cfg, list_id: String, mod_id: String) -> MLE<()> {
181 let data = devdir(format!("{}/data.db", config.data).as_str()); 181 let data = devdir(format!("{}/data.db", config.data).as_str());
182 let connection = Connection::open(data)?; 182 let connection = Connection::open(data)?;
183 183
@@ -186,7 +186,7 @@ pub fn userlist_remove(config: Cfg, list_id: String, mod_id: String) -> Result<(
186} 186}
187 187
188 188
189pub fn userlist_get_applicable_versions(config: Cfg, list_id: String, mod_id: String) -> Result<String, Box<dyn std::error::Error>> { 189pub fn userlist_get_applicable_versions(config: Cfg, list_id: String, mod_id: String) -> MLE<String> {
190 let data = devdir(format!("{}/data.db", config.data).as_str()); 190 let data = devdir(format!("{}/data.db", config.data).as_str());
191 let connection = Connection::open(data).unwrap(); 191 let connection = Connection::open(data).unwrap();
192 192
@@ -201,12 +201,12 @@ pub fn userlist_get_applicable_versions(config: Cfg, list_id: String, mod_id: St
201 }; 201 };
202 202
203 match version.is_empty() { 203 match version.is_empty() {
204 true => Err(Box::new(Error::new(ErrorKind::NotFound, "MOD_NOT_FOUND"))), 204 true => Err(MLError::new(ErrorType::DBError, "MOD_NOT_FOUND")),
205 false => Ok(version), 205 false => Ok(version),
206 } 206 }
207} 207}
208 208
209pub fn userlist_get_all_applicable_versions_with_mods(config: Cfg, list_id: String) -> Result<Vec<(String, String)>, Box<dyn std::error::Error>> { 209pub fn userlist_get_all_applicable_versions_with_mods(config: Cfg, list_id: String) -> MLE<Vec<(String, String)>> {
210 let data = devdir(format!("{}/data.db", config.data).as_str()); 210 let data = devdir(format!("{}/data.db", config.data).as_str());
211 let connection = Connection::open(data)?; 211 let connection = Connection::open(data)?;
212 212
@@ -221,7 +221,7 @@ pub fn userlist_get_all_applicable_versions_with_mods(config: Cfg, list_id: Stri
221 versions.push((out[0].to_owned(), out[1].to_owned())); 221 versions.push((out[0].to_owned(), out[1].to_owned()));
222 }; 222 };
223 223
224 if versions.is_empty() { return Err(Box::new(std::io::Error::new(ErrorKind::Other, "NO_MODS_ON_LIST"))); }; 224 if versions.is_empty() { return Err(MLError::new(ErrorType::DBError, "NO_MODS_ON_LIST")); };
225 225
226 Ok(versions) 226 Ok(versions)
227} 227}
@@ -349,6 +349,7 @@ pub fn userlist_get_all_downloads(config: Cfg, list_id: String) -> Result<Vec<St
349} 349}
350 350
351//lists 351//lists
352///Inserts into lists table and creates new table
352pub fn lists_insert(config: Cfg, id: String, mc_version: String, mod_loader: Modloader, download_folder: String) -> MLE<()> { 353pub fn lists_insert(config: Cfg, id: String, mc_version: String, mod_loader: Modloader, download_folder: String) -> MLE<()> {
353 println!("Creating list {}", id); 354 println!("Creating list {}", id);
354 355
@@ -420,7 +421,7 @@ pub fn lists_get_all_ids(config: Cfg) -> MLE<Vec<String>> {
420} 421}
421 422
422//config 423//config
423pub fn config_change_current_list(config: Cfg, id: String) -> Result<(), Box<dyn std::error::Error>> { 424pub fn config_change_current_list(config: Cfg, id: String) -> MLE<()> {
424 let data = devdir(format!("{}/data.db", config.data).as_str()); 425 let data = devdir(format!("{}/data.db", config.data).as_str());
425 let connection = Connection::open(data)?; 426 let connection = Connection::open(data)?;
426 427