diff options
Diffstat (limited to 'src/apis/modrinth.rs')
-rw-r--r-- | src/apis/modrinth.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index 525cc0d..9a22633 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs | |||
@@ -127,10 +127,13 @@ pub enum GameVersionType { | |||
127 | release, | 127 | release, |
128 | snapshot, | 128 | snapshot, |
129 | alpha, | 129 | alpha, |
130 | beta | 130 | beta, |
131 | } | 131 | } |
132 | 132 | ||
133 | async fn get(api: &str, path: &str) -> Result<Option<Vec<u8>>, Box<dyn std::error::Error>> { | 133 | async fn get( |
134 | api: &str, | ||
135 | path: &str, | ||
136 | ) -> Result<Option<Vec<u8>>, Box<dyn std::error::Error>> { | ||
134 | let url = format!(r#"{}{}"#, api, path); | 137 | let url = format!(r#"{}{}"#, api, path); |
135 | 138 | ||
136 | let client = Client::builder() | 139 | let client = Client::builder() |
@@ -170,7 +173,7 @@ pub async fn projects(api: &str, ids: Vec<String>) -> Vec<Project> { | |||
170 | pub async fn versions(api: &str, id: String, list: List) -> Vec<Version> { | 173 | pub async fn versions(api: &str, id: String, list: List) -> Vec<Version> { |
171 | let url = format!( | 174 | let url = format!( |
172 | r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, | 175 | r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, |
173 | id, list.modloader.to_string(), list.mc_version | 176 | id, list.modloader, list.mc_version |
174 | ); | 177 | ); |
175 | 178 | ||
176 | let data = get(api, &url).await.unwrap(); | 179 | let data = get(api, &url).await.unwrap(); |
@@ -182,7 +185,10 @@ pub async fn versions(api: &str, id: String, list: List) -> Vec<Version> { | |||
182 | } | 185 | } |
183 | 186 | ||
184 | ///Get version with the version ids | 187 | ///Get version with the version ids |
185 | pub async fn get_raw_versions(api: &str, versions: Vec<String>) -> Vec<Version> { | 188 | pub async fn get_raw_versions( |
189 | api: &str, | ||
190 | versions: Vec<String>, | ||
191 | ) -> Vec<Version> { | ||
186 | let url = format!(r#"versions?ids=["{}"]"#, versions.join(r#"",""#)); | 192 | let url = format!(r#"versions?ids=["{}"]"#, versions.join(r#"",""#)); |
187 | 193 | ||
188 | let data = get(api, &url).await.unwrap().unwrap(); | 194 | let data = get(api, &url).await.unwrap().unwrap(); |
@@ -208,7 +214,10 @@ pub fn extract_current_version(versions: Vec<Version>) -> MLE<String> { | |||
208 | } | 214 | } |
209 | 215 | ||
210 | pub async fn get_game_versions() -> Vec<GameVersion> { | 216 | pub async fn get_game_versions() -> Vec<GameVersion> { |
211 | let data = get("https://api.modrinth.com/v2/", "tag/game_version").await.unwrap().unwrap(); | 217 | let data = get("https://api.modrinth.com/v2/", "tag/game_version") |
218 | .await | ||
219 | .unwrap() | ||
220 | .unwrap(); | ||
212 | 221 | ||
213 | serde_json::from_slice(&data).unwrap() | 222 | serde_json::from_slice(&data).unwrap() |
214 | } | 223 | } |