use crate::manifest::{installer::Installer, link::Link}; use serde::{Deserialize, Serialize}; use std::collections::HashSet; use url::Url; pub mod installer; pub mod link; #[derive(Deserialize, Serialize, Debug)] pub struct Manifest { pub id: String, #[serde(rename = "type")] pub manifest_type: ManifestType, pub versions: Vec, pub repositories: Vec, pub meta: Meta, } #[derive(Deserialize, Serialize, Debug)] pub struct Meta { pub name: String, pub contributors: Vec, } #[derive(Deserialize, Serialize, Debug)] pub struct Contributor { pub name: String, pub roles: Vec, } #[derive(Deserialize, Serialize, Debug)] pub struct Repository { pub id: String, #[serde(rename = "type")] pub repo_type: RepositoryType, pub url: Url, } #[derive(Deserialize, Serialize, Debug, PartialEq, Eq)] #[serde(rename_all = "lowercase")] pub enum RepositoryType { Maven, Curseforge, } #[derive(Deserialize, Serialize, Debug)] pub struct Version { pub version: String, pub mcversion: Vec, #[serde(default)] pub files: Vec, #[serde(default)] pub relations: Vec, } #[derive(Deserialize, Serialize, Debug)] pub struct Relation { pub id: String, #[serde(skip_serializing_if = "Option::is_none")] pub file: Option, #[serde(skip_serializing_if = "Option::is_none")] pub versions: Option, #[serde(rename = "type")] pub relation_type: RelationType, pub options: HashSet, } #[derive(Deserialize, Serialize, Debug, Eq, PartialEq)] #[serde(rename_all = "lowercase")] pub enum RelationType { Mod, Modloader, } #[derive(Deserialize, Serialize, Debug, Hash, Eq, PartialEq)] #[serde(rename_all = "lowercase")] pub enum FileOpt { Required, Client, Server, Included, } #[derive(Deserialize, Serialize, Debug)] #[serde(untagged)] pub enum File { Link { id: Option, installer: Installer, link: Link, options: Option>, }, Maven { installer: Installer, artifact: String, repository: String, }, } impl File { pub fn installer(&self) -> &Installer { match self { File::Link { installer, .. } => installer, File::Maven { installer, .. } => installer, } } } #[derive(Deserialize, Serialize, Debug)] #[serde(rename_all = "lowercase")] pub enum ManifestType { Modpack, }