summaryrefslogtreecommitdiff
path: root/src/apis/modrinth.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2022-11-05 21:53:24 +0100
committerfxqnlr <[email protected]>2022-11-05 21:53:24 +0100
commit0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd (patch)
tree6262c397c500834cf6a06059394ac51328de3aed /src/apis/modrinth.rs
parent5d50f446a1a4612c0c931bdbc61f945760392f29 (diff)
downloadmodlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar
modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar.gz
modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.zip
added setup & download; direct input
Diffstat (limited to 'src/apis/modrinth.rs')
-rw-r--r--src/apis/modrinth.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs
index c71b47f..abb8eec 100644
--- a/src/apis/modrinth.rs
+++ b/src/apis/modrinth.rs
@@ -156,6 +156,16 @@ pub async fn versions(api: String, id: String, list: List) -> Vec<Version> {
156 serde_json::from_slice(&data.await.unwrap()).unwrap() 156 serde_json::from_slice(&data.await.unwrap()).unwrap()
157} 157}
158 158
159pub async fn get_raw_versions(api: String, versions: Vec<String>) -> Vec<Version> {
160 println!("Getting versions");
161
162 let url = format!(r#"versions?ids=["{}"]"#, versions.join(r#"",""#));
163
164 let data = get(api, url).await;
165
166 serde_json::from_slice(&data.unwrap()).unwrap()
167}
168
159pub fn extract_current_version(versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> { 169pub fn extract_current_version(versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> {
160 match versions.len() { 170 match versions.len() {
161 0 => Err(Box::new(Error::new(ErrorKind::NotFound, "NO_VERSIONS_AVAILABLE"))), 171 0 => Err(Box::new(Error::new(ErrorKind::NotFound, "NO_VERSIONS_AVAILABLE"))),