diff options
Diffstat (limited to 'src/apis/modrinth.rs')
-rw-r--r-- | src/apis/modrinth.rs | 10 |
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 | ||
156 | pub async fn project(api: &str, name: &str) -> Project { | 156 | pub 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 | ||
163 | pub async fn projects(api: &str, ids: Vec<String>) -> Vec<Project> { | 163 | pub 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 |
173 | 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> { |
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(); |