From 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 11:12:04 +0200 Subject: do nearly anything to shut clippy up --- src/apis/modrinth.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/apis/modrinth.rs') diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index 5366f3d..75e65e6 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs @@ -3,7 +3,7 @@ use reqwest::Client; use serde::{Deserialize, Serialize}; use crate::{ - error::{ErrorType, MLError, MLE}, + error::{EType, MLErr, MLE}, List, }; @@ -130,6 +130,8 @@ pub enum GameVersionType { beta, } +/// # Errors +/// # Panics async fn get( api: &str, path: &str, @@ -153,6 +155,8 @@ async fn get( Ok(data) } +/// # Errors +/// # Panics pub async fn project(api: &str, name: &str) -> Project { let url = format!("project/{name}"); let data = get(api, &url).await.unwrap().unwrap(); @@ -160,6 +164,8 @@ pub async fn project(api: &str, name: &str) -> Project { serde_json::from_slice(&data).unwrap() } +/// # Errors +/// # Panics pub async fn projects(api: &str, ids: Vec) -> Vec { let all = ids.join(r#"",""#); let url = format!(r#"projects?ids=["{all}"]"#); @@ -170,6 +176,8 @@ pub async fn projects(api: &str, ids: Vec) -> Vec { } ///Get applicable versions from `mod_id` with list context +/// # Errors +/// # Panics pub async fn versions(api: &str, id: String, list: List) -> Vec { let url = format!( r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, @@ -185,6 +193,8 @@ pub async fn versions(api: &str, id: String, list: List) -> Vec { } ///Get version with the version ids +/// # Errors +/// # Panics pub async fn get_raw_versions( api: &str, versions: Vec, @@ -196,9 +206,10 @@ pub async fn get_raw_versions( serde_json::from_slice(&data).unwrap() } +/// # Errors pub fn extract_current_version(versions: Vec) -> MLE { match versions.len() { - 0 => Err(MLError::new(ErrorType::ModError, "NO_VERSIONS_AVAILABLE")), + 0 => Err(MLErr::new(EType::ModError, "NO_VERSIONS_AVAILABLE")), 1.. => { let mut times: Vec<(String, DateTime)> = vec![]; for ver in versions { @@ -209,10 +220,11 @@ pub fn extract_current_version(versions: Vec) -> MLE { times.reverse(); Ok(times[0].0.to_string()) } - _ => panic!("available_versions should never be negative"), } } +/// # Errors +/// # Panics pub async fn get_game_versions() -> Vec { let data = get("https://api.modrinth.com/v2/", "tag/game_version") .await -- cgit v1.2.3