1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use ferinth::structures::project::ProjectSupportRange;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
use url::Url;

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
    /// The version of the format, stored as a number.
    /// The current value at the time of writing is `1`.
    pub format_version: u64,
    pub game: Game,
    pub version_id: String,
    /// Human readable name of the modpack
    pub name: String,
    /// A short description of this modpack
    pub summary: Option<String>,
    /// A list of files for the modpack that needs
    pub files: Vec<ModpackFile>,
    /// A list of IDs and version numbers that launchers will use in order to know what to install
    pub dependencies: HashMap<DependencyID, String>,
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
#[serde(rename_all = "kebab-case")]
pub enum DependencyID {
    Minecraft,
    Forge,
    FabricLoader,
    QuiltLoader,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ModpackFile {
    /// The destination path of this file, relative to the Minecraft instance directory
    pub path: PathBuf,
    pub hashes: ModpackFileHashes,
    /// The specific environment this file exists on
    pub env: Option<ModpackFileEnvironment>,
    /// HTTPS URLs where this file may be downloaded
    pub downloads: Vec<Url>,
    /// The size of the file in bytes
    pub file_size: u64,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ModpackFileHashes {
    sha1: String,
    sha512: String,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ModpackFileEnvironment {
    client: ProjectSupportRange,
    server: ProjectSupportRange,
}

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum Game {
    Minecraft,
}