You've already forked AstralRinth
forked from didirus/AstralRinth
Fix clippy issues
This commit is contained in:
@@ -57,7 +57,7 @@ impl Metadata {
|
||||
|
||||
if let Some(ref meta_bin) = db.get(METADATA_DB_FIELD)? {
|
||||
match bincode::decode_from_slice::<Self, _>(
|
||||
&meta_bin,
|
||||
meta_bin,
|
||||
*BINCODE_CONFIG,
|
||||
) {
|
||||
Ok((meta, _)) => metadata = Some(meta),
|
||||
|
||||
@@ -18,7 +18,7 @@ pub(crate) struct Profiles(pub HashMap<PathBuf, Option<Profile>>);
|
||||
|
||||
// TODO: possibly add defaults to some of these values
|
||||
pub const CURRENT_FORMAT_VERSION: u32 = 1;
|
||||
pub const SUPPORTED_ICON_FORMATS: &[&'static str] = &[
|
||||
pub const SUPPORTED_ICON_FORMATS: &[&str] = &[
|
||||
"bmp", "gif", "jpeg", "jpg", "jpe", "png", "svg", "svgz", "webp", "rgb",
|
||||
"mp4",
|
||||
];
|
||||
@@ -54,26 +54,23 @@ pub struct ProfileMetadata {
|
||||
}
|
||||
|
||||
// TODO: Quilt?
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, Deserialize, Serialize)]
|
||||
#[derive(
|
||||
Debug, Eq, PartialEq, Clone, Copy, Deserialize, Serialize, Default,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ModLoader {
|
||||
#[default]
|
||||
Vanilla,
|
||||
Forge,
|
||||
Fabric,
|
||||
}
|
||||
|
||||
impl Default for ModLoader {
|
||||
fn default() -> Self {
|
||||
ModLoader::Vanilla
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ModLoader {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
&Self::Vanilla => "Vanilla",
|
||||
&Self::Forge => "Forge",
|
||||
&Self::Fabric => "Fabric",
|
||||
f.write_str(match *self {
|
||||
Self::Vanilla => "Vanilla",
|
||||
Self::Forge => "Forge",
|
||||
Self::Fabric => "Fabric",
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -237,7 +234,7 @@ impl Profiles {
|
||||
// project path, parent profile path
|
||||
let mut files: HashMap<PathBuf, PathBuf> = HashMap::new();
|
||||
{
|
||||
for (profile_path, _profile_optZA) in profiles.iter() {
|
||||
for (profile_path, _profile_opt) in profiles.iter() {
|
||||
let mut read_paths = |path: &str| {
|
||||
for path in std::fs::read_dir(profile_path.join(path))? {
|
||||
files.insert(path?.path(), profile_path.clone());
|
||||
@@ -252,17 +249,15 @@ impl Profiles {
|
||||
}
|
||||
}
|
||||
let inferred = super::projects::infer_data_from_files(
|
||||
files.keys().into_iter().cloned().collect(),
|
||||
files.keys().cloned().collect(),
|
||||
dirs.caches_dir(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
for (key, value) in inferred {
|
||||
if let Some(profile_path) = files.get(&key) {
|
||||
if let Some(profile) = profiles.get_mut(profile_path) {
|
||||
if let Some(profile) = profile {
|
||||
profile.projects.insert(key, value);
|
||||
}
|
||||
if let Some(Some(profile)) = profiles.get_mut(profile_path) {
|
||||
profile.projects.insert(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ pub struct ModrinthProject {
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ProjectMetadata {
|
||||
Modrinth(ModrinthProject),
|
||||
Modrinth(Box<ModrinthProject>),
|
||||
Inferred {
|
||||
title: Option<String>,
|
||||
description: Option<String>,
|
||||
@@ -126,7 +126,9 @@ pub async fn infer_data_from_files(
|
||||
Project {
|
||||
sha512: hash,
|
||||
disabled: false,
|
||||
metadata: ProjectMetadata::Modrinth(project.clone()),
|
||||
metadata: ProjectMetadata::Modrinth(Box::new(
|
||||
project.clone(),
|
||||
)),
|
||||
},
|
||||
);
|
||||
continue;
|
||||
@@ -342,10 +344,7 @@ pub async fn infer_data_from_files(
|
||||
if file.read_to_string(&mut file_str).is_ok() {
|
||||
if let Ok(pack) = serde_json::from_str::<QuiltMod>(&file_str) {
|
||||
let icon = read_icon_from_file(
|
||||
pack.metadata
|
||||
.as_ref()
|
||||
.map(|x| x.icon.clone())
|
||||
.flatten(),
|
||||
pack.metadata.as_ref().and_then(|x| x.icon.clone()),
|
||||
)?;
|
||||
|
||||
return_projects.insert(
|
||||
@@ -357,15 +356,13 @@ pub async fn infer_data_from_files(
|
||||
title: Some(
|
||||
pack.metadata
|
||||
.as_ref()
|
||||
.map(|x| x.name.clone())
|
||||
.flatten()
|
||||
.and_then(|x| x.name.clone())
|
||||
.unwrap_or(pack.id),
|
||||
),
|
||||
description: pack
|
||||
.metadata
|
||||
.as_ref()
|
||||
.map(|x| x.description.clone())
|
||||
.flatten(),
|
||||
.and_then(|x| x.description.clone()),
|
||||
authors: pack
|
||||
.metadata
|
||||
.map(|x| {
|
||||
|
||||
@@ -103,7 +103,7 @@ impl Default for WindowSize {
|
||||
}
|
||||
|
||||
/// Game initialization hooks
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
#[serde(default)]
|
||||
pub struct Hooks {
|
||||
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
||||
@@ -113,13 +113,3 @@ pub struct Hooks {
|
||||
#[serde(skip_serializing_if = "HashSet::is_empty")]
|
||||
pub post_exit: HashSet<String>,
|
||||
}
|
||||
|
||||
impl Default for Hooks {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pre_launch: HashSet::<String>::new(),
|
||||
wrapper: None,
|
||||
post_exit: HashSet::<String>::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user