Skip to content

Commit

Permalink
mod_info can now accept an object in version field
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain Laird committed Jun 14, 2021
1 parent a598a4d commit 902d1a7
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/gui/mod_list.rs
Expand Up @@ -547,6 +547,7 @@ impl ModList {
version
))
} else {
dbg!(entry.path());
None
}
})
Expand Down Expand Up @@ -669,13 +670,36 @@ impl Display for UpdateStatus {

pub struct UpdateStatusTTPatch(pub UpdateStatus);

#[derive(Debug, Clone, Deserialize)]
#[serde(untagged)]
enum VersionUnion {
String(String),
Object(ModVersion)
}

impl Display for VersionUnion {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
let output: String = match self {
VersionUnion::String(s) => s.to_string(),
VersionUnion::Object(o) => o.to_string()
};
write!(f, "{}", output)
}
}

impl From<VersionUnion> for String {
fn from(version_union: VersionUnion) -> Self {
version_union.to_string()
}
}

#[derive(Debug, Clone, Deserialize)]
pub struct ModEntry {
pub id: String,
name: String,
#[serde(default)]
author: String,
version: String,
version: VersionUnion,
description: String,
#[serde(alias = "gameVersion")]
game_version: String,
Expand Down

0 comments on commit 902d1a7

Please sign in to comment.