treewide: fix clippy lints
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I411be69ff31f9cb39cd4cdebc8985b366a6a6964
This commit is contained in:
parent
b93b234fc2
commit
61ced09d25
43 changed files with 558 additions and 464 deletions
|
|
@ -32,7 +32,10 @@ impl CurseForgePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
pub const fn with_client(client: Arc<Client>, api_key: Option<String>) -> Self {
|
||||
pub const fn with_client(
|
||||
client: Arc<Client>,
|
||||
api_key: Option<String>,
|
||||
) -> Self {
|
||||
Self { client, api_key }
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +60,6 @@ impl CurseForgePlatform {
|
|||
|
||||
const fn map_class_id(class_id: u32) -> ProjectType {
|
||||
match class_id {
|
||||
6 => ProjectType::Mod,
|
||||
12 => ProjectType::ResourcePack,
|
||||
6945 => ProjectType::DataPack,
|
||||
6552 => ProjectType::Shader,
|
||||
|
|
@ -68,7 +70,6 @@ impl CurseForgePlatform {
|
|||
|
||||
const fn map_release_type(release_type: u32) -> ReleaseType {
|
||||
match release_type {
|
||||
1 => ReleaseType::Release,
|
||||
2 => ReleaseType::Beta,
|
||||
3 => ReleaseType::Alpha,
|
||||
_ => ReleaseType::Release,
|
||||
|
|
@ -142,7 +143,7 @@ impl CurseForgePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
fn convert_project(&self, cf_project: CurseForgeProject) -> Project {
|
||||
fn convert_project(cf_project: CurseForgeProject) -> Project {
|
||||
let pakku_id = generate_pakku_id();
|
||||
let project_type = Self::map_class_id(cf_project.class_id.unwrap_or(6));
|
||||
|
||||
|
|
@ -162,11 +163,7 @@ impl CurseForgePlatform {
|
|||
project
|
||||
}
|
||||
|
||||
fn convert_file(
|
||||
&self,
|
||||
cf_file: CurseForgeFile,
|
||||
project_id: &str,
|
||||
) -> ProjectFile {
|
||||
fn convert_file(cf_file: CurseForgeFile, project_id: &str) -> ProjectFile {
|
||||
let mut hashes = HashMap::new();
|
||||
|
||||
for hash in cf_file.hashes {
|
||||
|
|
@ -259,12 +256,12 @@ impl PlatformClient for CurseForgePlatform {
|
|||
|
||||
if response.status().is_success() {
|
||||
let result: CurseForgeProjectResponse = response.json().await?;
|
||||
return Ok(self.convert_project(result.data));
|
||||
return Ok(Self::convert_project(result.data));
|
||||
}
|
||||
}
|
||||
|
||||
let cf_project = self.search_project_by_slug(identifier).await?;
|
||||
Ok(self.convert_project(cf_project))
|
||||
Ok(Self::convert_project(cf_project))
|
||||
}
|
||||
|
||||
async fn request_project_files(
|
||||
|
|
@ -319,7 +316,7 @@ impl PlatformClient for CurseForgePlatform {
|
|||
let files: Vec<ProjectFile> = result
|
||||
.data
|
||||
.into_iter()
|
||||
.map(|f| self.convert_file(f, project_id))
|
||||
.map(|f| Self::convert_file(f, project_id))
|
||||
.collect();
|
||||
|
||||
Ok(files)
|
||||
|
|
@ -398,7 +395,7 @@ impl PlatformClient for CurseForgePlatform {
|
|||
) -> Result<Option<Project>> {
|
||||
// Try to fetch project by slug using search API
|
||||
match self.search_project_by_slug(slug).await {
|
||||
Ok(cf_project) => Ok(Some(self.convert_project(cf_project))),
|
||||
Ok(cf_project) => Ok(Some(Self::convert_project(cf_project))),
|
||||
Err(PakkerError::ProjectNotFound(_)) => Ok(None),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
|
|
@ -411,6 +408,11 @@ impl PlatformClient for CurseForgePlatform {
|
|||
hashes: &[String],
|
||||
_algorithm: &str,
|
||||
) -> Result<Vec<Project>> {
|
||||
#[derive(Serialize)]
|
||||
struct FingerprintRequest {
|
||||
fingerprints: Vec<u32>,
|
||||
}
|
||||
|
||||
if hashes.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
|
@ -424,11 +426,6 @@ impl PlatformClient for CurseForgePlatform {
|
|||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct FingerprintRequest {
|
||||
fingerprints: Vec<u32>,
|
||||
}
|
||||
|
||||
let url = format!("{CURSEFORGE_API_BASE}/fingerprints/432");
|
||||
let response = self
|
||||
.client
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue