Skip to main content

elemental_schema/mojang/piston/
version_metadata.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use super::asset_index::PistonMetaAssetIndex;
6
7/// https://piston-meta.mojang.com/v1/packages/<sha1>/<id>.json
8#[derive(Debug, Clone, Deserialize, Serialize)]
9pub struct PistonMetaData {
10    pub arguments: Option<PistonMetaArguments>,
11    #[serde(rename = "minecraftArguments")]
12    pub minecraft_arguments: Option<String>,
13    #[serde(rename = "inheritsFrom", default)]
14    pub inherits_from: Option<String>,
15    #[serde(rename = "assetIndex")]
16    pub asset_index: PistonMetaAssetIndex,
17    pub assets: String,
18    #[serde(rename = "complianceLevel")]
19    pub compliance_level: usize,
20    pub downloads: PistonMetaDownloads,
21    pub id: String,
22    #[serde(rename = "javaVersion")]
23    pub java_version: PistonMetaJavaVersion,
24    pub libraries: Vec<PistonMetaLibraries>,
25    pub logging: Option<PistonMetaLogging>,
26    #[serde(rename = "mainClass")]
27    pub main_class: String,
28    #[serde(rename = "minimumLauncherVersion")]
29    pub minimum_launcher_version: usize,
30    #[serde(rename = "type")]
31    pub release_type: String,
32    pub time: String,
33    #[serde(rename = "releaseTime")]
34    pub release_time: String,
35}
36
37#[derive(Debug, Clone, Deserialize, Serialize)]
38pub struct PistonMetaArguments {
39    #[serde(default)]
40    pub game: Vec<PistonMetaGenericArgument>,
41    #[serde(default)]
42    pub jvm: Vec<PistonMetaGenericArgument>,
43}
44
45#[derive(Debug, Clone, Deserialize, Serialize)]
46#[serde(untagged)]
47pub enum PistonMetaGenericArgument {
48    Plain(String),
49    Rule(PistonMetaRuleArgument),
50}
51
52#[derive(Debug, Clone, Deserialize, Serialize)]
53pub struct PistonMetaRuleArgument {
54    pub rules: Vec<PistonMetaRuleArgumentRules>,
55    pub value: Option<ContinuousArgument>,
56}
57
58#[derive(Debug, Clone, Deserialize, Serialize)]
59pub struct PistonMetaRuleArgumentRules {
60    pub action: String,
61    pub features: Option<HashMap<String, bool>>,
62    pub os: Option<OperatingSystem>,
63}
64
65#[derive(Debug, Clone, Deserialize, Serialize)]
66pub struct OperatingSystem {
67    pub arch: Option<String>,
68    pub name: Option<String>,
69    pub version: Option<String>,
70}
71
72#[derive(Debug, Clone, Deserialize, Serialize)]
73#[serde(untagged)]
74pub enum ContinuousArgument {
75    Single(String),
76    Multi(Vec<String>),
77}
78
79#[derive(Debug, Clone, Deserialize, Serialize)]
80pub struct PistonMetaDownloads {
81    pub client: PistonMetaDownload,
82}
83
84#[derive(Debug, Clone, Deserialize, Serialize)]
85pub struct PistonMetaDownload {
86    pub sha1: String,
87    pub size: usize,
88    pub url: String,
89}
90
91#[derive(Debug, Clone, Deserialize, Serialize)]
92pub struct PistonMetaJavaVersion {
93    pub component: String,
94    #[serde(rename = "majorVersion")]
95    pub major_version: usize,
96}
97
98#[derive(Debug, Clone, Deserialize, Serialize)]
99pub struct PistonMetaLibraries {
100    pub downloads: PistonMetaLibrariesDownloads,
101    pub name: String,
102    pub natives: Option<HashMap<String, String>>,
103    pub rules: Option<Vec<PistonMetaRuleArgumentRules>>,
104    pub extract: Option<PistonMetaLibrariesExtract>,
105}
106
107#[derive(Debug, Clone, Deserialize, Serialize)]
108pub struct PistonMetaLibrariesExtract {
109    pub exclude: Vec<String>,
110}
111
112#[derive(Debug, Clone, Deserialize, Serialize)]
113pub struct PistonMetaLibrariesDownloads {
114    pub artifact: Option<PistonMetaLibrariesDownloadsArtifact>,
115    pub classifiers: Option<HashMap<String, PistonMetaLibrariesDownloadsArtifact>>,
116}
117
118#[derive(Debug, Clone, Deserialize, Serialize)]
119pub struct PistonMetaLibrariesDownloadsArtifact {
120    pub sha1: Option<String>,
121    pub size: Option<usize>,
122    pub url: String,
123    pub path: String,
124}
125
126#[derive(Debug, Clone, Deserialize, Serialize)]
127pub struct PistonMetaLogging {
128    #[serde(default)]
129    pub client: Option<PistonMetaLoggingSide>,
130}
131
132#[derive(Debug, Clone, Deserialize, Serialize)]
133pub struct PistonMetaLoggingSide {
134    pub argument: String,
135    pub file: PistonMetaLoggingSideFile,
136    #[serde(rename = "type")]
137    pub logging_type: String,
138}
139
140#[derive(Debug, Clone, Deserialize, Serialize)]
141pub struct PistonMetaLoggingSideFile {
142    pub id: String,
143    pub sha1: String,
144    pub size: usize,
145    pub url: String,
146}