Skip to content

Commit

Permalink
fix!: Add new fields to the manifest
Browse files Browse the repository at this point in the history
BREAKING CHANGE
  • Loading branch information
sargon64 committed Jul 9, 2023
1 parent a9e7462 commit ce53bcc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
bincode = "1.3.3"
bytes = "1.4.0"
semver = { version = "1.0.17", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
serde_json = "1.0.99"
Expand Down
2 changes: 1 addition & 1 deletion src/structs/forgemod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use xz2::{read::XzDecoder, write::XzEncoder};
use super::manifest::ForgeManifest;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ForgeMod {
pub manifest: ForgeManifest,
#[serde(with = "serde_bytes")]
Expand Down
39 changes: 33 additions & 6 deletions src/structs/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@
use std::{path::PathBuf, str::FromStr};

use serde::{Deserialize, Serialize};
use semver::{Version, VersionReq};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ForgeManifest {
pub manifest_version: u32,

/// The mod's unique identifier. A slug. Not to be confused with the mod's ObjectId.
pub _id: String,
pub name: String,
pub description: String,
pub website: String,
pub author: String,
pub version: String,
pub game_version: String,
pub version: Version,
pub game_version: VersionReq,
pub artifact: String,

pub pre_exec: String,
pub post_exec: String,
pub includes: Vec<Include>,

pub depends: Vec<Depends>, // slug, version
pub conflicts: Vec<Depends>, // slug, version
pub category: ModCategory,
Expand All @@ -31,8 +37,8 @@ pub struct Include {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Depends {
pub name: String,
pub version: String,
pub id: String,
pub version: VersionReq,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -65,6 +71,27 @@ impl TryFrom<PathBuf> for ForgeManifest {
}
}

impl ToString for ModCategory {
fn to_string(&self) -> String {
match self {
ModCategory::Core => "core".to_string(),
ModCategory::Libraries => "libraries".to_string(),
ModCategory::Cosmetic => "cosmetic".to_string(),
ModCategory::Gameplay => "gameplay".to_string(),
ModCategory::Leaderboards => "leaderboards".to_string(),
ModCategory::Lighting => "lighting".to_string(),
ModCategory::Multiplayer => "multiplayer".to_string(),
ModCategory::Accessibility => "accessibility".to_string(),
ModCategory::Practice => "practice".to_string(),
ModCategory::Streaming => "streaming".to_string(),
ModCategory::Text => "text".to_string(),
ModCategory::Tweaks => "tweaks".to_string(),
ModCategory::UI => "ui".to_string(),
ModCategory::Other => "other".to_string(),
}
}
}

impl FromStr for ModCategory {
type Err = ();

Expand Down

0 comments on commit ce53bcc

Please sign in to comment.