From 9c984cef9a2d0fb223635617934959480e8ca2df Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 19 Feb 2023 11:49:23 +0100 Subject: Added adding of specific mod-version --- src/apis/modrinth.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/apis') diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index f3f89a7..bb5ee19 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs @@ -108,7 +108,7 @@ pub struct Hash { pub sha1: String, } -async fn get(api: String, path: String) -> Result>, Box> { +async fn get(api: &str, path: String) -> Result>, Box> { let url = format!(r#"{}{}"#, api, path); let client = Client::builder() @@ -131,14 +131,14 @@ async fn get(api: String, path: String) -> Result>, Box Project { +pub async fn project(api: &str, name: &str) -> Project { let url = format!("project/{}", name); let data = get(api, url).await.unwrap().unwrap(); serde_json::from_slice(&data).unwrap() } -pub async fn projects(api: String, ids: Vec) -> Vec { +pub async fn projects(api: &str, ids: Vec) -> Vec { let all = ids.join(r#"",""#); let url = format!(r#"projects?ids=["{}"]"#, all); @@ -147,7 +147,8 @@ pub async fn projects(api: String, ids: Vec) -> Vec { serde_json::from_slice(&data).unwrap() } -pub async fn versions(api: String, id: String, list: List) -> Vec { +///Get applicable versions from mod_id with list context +pub async fn versions(api: &str, id: String, list: List) -> Vec { let loaderstr = match list.modloader { Modloader::Forge => String::from("forge"), Modloader::Fabric => String::from("fabric"), @@ -163,9 +164,8 @@ pub async fn versions(api: String, id: String, list: List) -> Vec { } } -pub async fn get_raw_versions(api: String, versions: Vec) -> Vec { - println!("Getting versions {}", &versions.join(", ")); - +///Get version with the version ids +pub async fn get_raw_versions(api: &str, versions: Vec) -> Vec { let url = format!(r#"versions?ids=["{}"]"#, versions.join(r#"",""#)); let data = get(api, url).await.unwrap().unwrap(); @@ -204,7 +204,7 @@ pub struct MCVersion { pub major: bool, } -pub async fn get_minecraft_version(api: String, version: MCVersionType) -> String { +pub async fn get_minecraft_version(api: &str, version: MCVersionType) -> String { let data = get(api, String::from("tag/game_version")).await.unwrap().unwrap(); let mc_versions: Vec = serde_json::from_slice(&data).unwrap(); let ver = match version { -- cgit v1.2.3