summaryrefslogtreecommitdiff
path: root/src/apis
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
committerfxqnlr <[email protected]>2024-09-04 09:56:42 +0200
commitf5e070cdf6628a5ebd981d373929802317104e24 (patch)
treee31c88371737e20b2cc79bf9ee0c1dbfdeb6e727 /src/apis
parent1d64516ed95266a4fc1f8a18652f99158a4004f1 (diff)
downloadmodlist-f5e070cdf6628a5ebd981d373929802317104e24.tar
modlist-f5e070cdf6628a5ebd981d373929802317104e24.tar.gz
modlist-f5e070cdf6628a5ebd981d373929802317104e24.zip
clippy --fix
Diffstat (limited to 'src/apis')
-rw-r--r--src/apis/modrinth.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs
index 9a22633..5366f3d 100644
--- a/src/apis/modrinth.rs
+++ b/src/apis/modrinth.rs
@@ -134,7 +134,7 @@ async fn get(
134 api: &str, 134 api: &str,
135 path: &str, 135 path: &str,
136) -> Result<Option<Vec<u8>>, Box<dyn std::error::Error>> { 136) -> Result<Option<Vec<u8>>, Box<dyn std::error::Error>> {
137 let url = format!(r#"{}{}"#, api, path); 137 let url = format!(r#"{api}{path}"#);
138 138
139 let client = Client::builder() 139 let client = Client::builder()
140 .user_agent(format!( 140 .user_agent(format!(
@@ -154,7 +154,7 @@ async fn get(
154} 154}
155 155
156pub async fn project(api: &str, name: &str) -> Project { 156pub async fn project(api: &str, name: &str) -> Project {
157 let url = format!("project/{}", name); 157 let url = format!("project/{name}");
158 let data = get(api, &url).await.unwrap().unwrap(); 158 let data = get(api, &url).await.unwrap().unwrap();
159 159
160 serde_json::from_slice(&data).unwrap() 160 serde_json::from_slice(&data).unwrap()
@@ -162,14 +162,14 @@ pub async fn project(api: &str, name: &str) -> Project {
162 162
163pub async fn projects(api: &str, ids: Vec<String>) -> Vec<Project> { 163pub async fn projects(api: &str, ids: Vec<String>) -> Vec<Project> {
164 let all = ids.join(r#"",""#); 164 let all = ids.join(r#"",""#);
165 let url = format!(r#"projects?ids=["{}"]"#, all); 165 let url = format!(r#"projects?ids=["{all}"]"#);
166 166
167 let data = get(api, &url).await.unwrap().unwrap(); 167 let data = get(api, &url).await.unwrap().unwrap();
168 168
169 serde_json::from_slice(&data).unwrap() 169 serde_json::from_slice(&data).unwrap()
170} 170}
171 171
172///Get applicable versions from mod_id with list context 172///Get applicable versions from `mod_id` with list context
173pub async fn versions(api: &str, id: String, list: List) -> Vec<Version> { 173pub async fn versions(api: &str, id: String, list: List) -> Vec<Version> {
174 let url = format!( 174 let url = format!(
175 r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#, 175 r#"project/{}/version?loaders=["{}"]&game_versions=["{}"]"#,
@@ -203,7 +203,7 @@ pub fn extract_current_version(versions: Vec<Version>) -> MLE<String> {
203 let mut times: Vec<(String, DateTime<FixedOffset>)> = vec![]; 203 let mut times: Vec<(String, DateTime<FixedOffset>)> = vec![];
204 for ver in versions { 204 for ver in versions {
205 let stamp = DateTime::parse_from_rfc3339(&ver.date_published)?; 205 let stamp = DateTime::parse_from_rfc3339(&ver.date_published)?;
206 times.push((ver.id, stamp)) 206 times.push((ver.id, stamp));
207 } 207 }
208 times.sort_by_key(|t| t.1); 208 times.sort_by_key(|t| t.1);
209 times.reverse(); 209 times.reverse();