From 96cc5257de09682df345e768dc2a91303f9b36c9 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 3 Nov 2022 21:34:04 +0100 Subject: added update beginnings; init of tests --- src/apis/modrinth.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/apis') diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index 3af5bbd..0c3eca5 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs @@ -1,6 +1,6 @@ use serde::Deserialize; -use crate::Modloader; +use crate::{Modloader, List}; #[derive(Debug, Deserialize)] pub struct Project { @@ -68,7 +68,7 @@ pub enum Status { unknown } -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct Version { pub name: String, pub version_number: String, @@ -86,14 +86,14 @@ pub struct Version { } #[allow(non_camel_case_types)] -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub enum VersionType { release, beta, alpha } -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct VersionFile { pub hashes: Hash, pub url: String, @@ -102,7 +102,7 @@ pub struct VersionFile { pub size: u32, } -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct Hash { pub sha512: String, pub sha1: String, @@ -130,7 +130,7 @@ pub async fn project(api: String, name: &str) -> Project { serde_json::from_slice(&data.await.unwrap()).unwrap() } -pub async fn projects(api: String, ids: Vec<&str>) -> Vec { +pub async fn projects(api: String, ids: Vec) -> Vec { let all = ids.join(r#"",""#); let url = format!(r#"projects?ids=["{}"]"#, all); println!("{}", url); @@ -140,14 +140,14 @@ pub async fn projects(api: String, ids: Vec<&str>) -> Vec { serde_json::from_slice(&data.await.unwrap()).unwrap() } -pub async fn versions(api: String, id: String, loader: Modloader, mc_version: String) -> Vec { +pub async fn versions(api: String, id: String, list: List) -> Vec { - let loaderstr = match loader { + let loaderstr = match list.modloader { Modloader::Forge => String::from("forge"), Modloader::Fabric => String::from("fabric"), }; - let url = format!(r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, id, loaderstr, mc_version); + let url = format!(r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, id, loaderstr, list.mc_version); let data = get(api, url); -- cgit v1.2.3