summaryrefslogtreecommitdiffstats
path: root/src/version.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/version.rs')
-rw-r--r--src/version.rs158
1 files changed, 60 insertions, 98 deletions
diff --git a/src/version.rs b/src/version.rs
index d120093..0c1e65f 100644
--- a/src/version.rs
+++ b/src/version.rs
@@ -65,46 +65,20 @@ impl<'de> Deserialize<'de> for WrappedRegex {
#[derive(Deserialize, Debug)]
pub struct OSRestriction {
- name: Option<OperatingSystem>,
+ pub name: Option<OperatingSystem>,
- version: Option<WrappedRegex>,
- arch: Option<WrappedRegex>
-}
-
-impl OSRestriction {
- pub fn get_name(&self) -> Option<OperatingSystem> {
- self.name
- }
-
- pub fn get_version(&self) -> Option<&Regex> {
- self.version.as_deref()
- }
-
- pub fn get_arch(&self) -> Option<&Regex> {
- self.arch.as_deref()
- }
+ pub version: Option<WrappedRegex>,
+ pub arch: Option<WrappedRegex>
}
#[derive(Deserialize, Debug)]
pub struct CompatibilityRule {
- action: RuleAction,
- features: Option<BTreeMap<String, bool>>,
- os: Option<OSRestriction>
+ pub action: RuleAction,
+ pub features: Option<BTreeMap<String, bool>>,
+ pub os: Option<OSRestriction>
}
impl CompatibilityRule {
- pub fn get_action(&self) -> RuleAction {
- self.action
- }
-
- pub fn get_os(&self) -> Option<&OSRestriction> {
- self.os.as_ref()
- }
-
- pub fn get_features(&self) -> Option<&BTreeMap<String, bool>> {
- self.features.as_ref()
- }
-
pub fn features_match(&self, checker: fn(&str) -> bool) -> bool {
if let Some(m) = self.features.as_ref() {
for (feat, expect) in m {
@@ -121,21 +95,11 @@ impl CompatibilityRule {
#[derive(Deserialize, Debug)]
pub struct Argument {
#[serde(default)]
- rules: Option<Vec<CompatibilityRule>>,
+ pub rules: Option<Vec<CompatibilityRule>>,
#[serde(default)]
#[serde(deserialize_with = "string_or_array")]
- value: Vec<String>
-}
-
-impl Argument {
- fn get_rules(&self) -> Option<&Vec<CompatibilityRule>> {
- self.rules.as_ref()
- }
-
- fn get_value(&self) -> &Vec<String> {
- &self.value
- }
+ pub value: Vec<String>
}
#[derive(Debug)]
@@ -170,18 +134,8 @@ impl<'de> Deserialize<'de> for WrappedArgument {
#[derive(Deserialize, Debug)]
pub struct Arguments {
- game: Option<Vec<WrappedArgument>>,
- jvm: Option<Vec<WrappedArgument>>
-}
-
-impl Arguments {
- fn get_game(&self) -> Option<&Vec<WrappedArgument>> {
- self.game.as_ref()
- }
-
- fn get_jvm(&self) -> Option<&Vec<WrappedArgument>> {
- self.jvm.as_ref()
- }
+ pub game: Option<Vec<WrappedArgument>>,
+ pub jvm: Option<Vec<WrappedArgument>>
}
#[derive(Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
@@ -196,91 +150,93 @@ pub enum DownloadType {
#[derive(Deserialize, Debug)]
pub struct DownloadInfo {
- sha1: Option<String>,
- size: Option<usize>,
- total_size: Option<usize>, // available for asset index
- url: Option<String>, // may not be present for libraries
- id: Option<String>,
- path: Option<String>
+ pub sha1: Option<String>,
+ pub size: Option<usize>,
+ pub total_size: Option<usize>, // available for asset index
+ pub url: Option<String>, // may not be present for libraries
+ pub id: Option<String>,
+ pub path: Option<String>
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct JavaVersionInfo {
- component: String,
- major_version: u32
+ pub component: String,
+ pub major_version: u32
}
#[derive(Deserialize, Debug)]
pub struct LibraryDownloads {
- artifact: Option<DownloadInfo>,
- classifiers: Option<BTreeMap<String, DownloadInfo>>
+ pub artifact: Option<DownloadInfo>,
+ pub classifiers: Option<BTreeMap<String, DownloadInfo>>
}
#[derive(Deserialize, Debug)]
pub struct LibraryExtractRule {
#[serde(default)]
- exclude: Vec<String>
+ pub exclude: Vec<String>
}
#[derive(Deserialize, Debug)]
pub struct Library {
- downloads: Option<LibraryDownloads>,
- name: String,
- extract: Option<LibraryExtractRule>,
- natives: Option<BTreeMap<OperatingSystem, String>>,
- rules: Option<Vec<CompatibilityRule>>,
- url: Option<String> // old format
+ pub downloads: Option<LibraryDownloads>,
+ pub name: String,
+ pub extract: Option<LibraryExtractRule>,
+ pub natives: Option<BTreeMap<OperatingSystem, String>>,
+ pub rules: Option<Vec<CompatibilityRule>>,
+ pub url: Option<String> // old format
}
#[derive(Deserialize, Debug)]
pub struct ClientLogging {
- argument: String,
- r#type: String,
- file: DownloadInfo
+ pub argument: String,
+
+ #[serde(rename = "type")]
+ pub logger_type: String,
+ pub file: DownloadInfo
}
#[derive(Deserialize, Debug)]
pub struct Logging {
- client: ClientLogging // other fields unknown
+ pub client: ClientLogging // other fields unknown
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CompleteVersion {
- arguments: Option<Arguments>,
- minecraft_arguments: Option<String>,
+ pub arguments: Option<Arguments>,
+ pub minecraft_arguments: Option<String>,
- asset_index: Option<DownloadInfo>,
- assets: Option<String>,
+ pub asset_index: Option<DownloadInfo>,
+ pub assets: Option<String>,
- compliance_level: Option<u32>,
+ pub compliance_level: Option<u32>,
- java_version: Option<JavaVersionInfo>,
+ pub java_version: Option<JavaVersionInfo>,
#[serde(default)]
- downloads: BTreeMap<DownloadType, DownloadInfo>,
+ pub downloads: BTreeMap<DownloadType, DownloadInfo>,
#[serde(default)]
- libraries: Vec<Library>,
+ pub libraries: Vec<Library>,
- id: String,
- jar: Option<String>, // used as the jar filename if specified? (no longer used officially)
+ pub id: String,
+ pub jar: Option<String>, // used as the jar filename if specified? (no longer used officially)
- logging: Option<Logging>,
+ pub logging: Option<Logging>,
- main_class: Option<String>,
- minimum_launcher_version: Option<u32>,
- release_time: Option<DateTime<Utc>>,
- time: Option<DateTime<Utc>>,
+ pub main_class: Option<String>,
+ pub minimum_launcher_version: Option<u32>,
+ pub release_time: Option<DateTime<Utc>>,
+ pub time: Option<DateTime<Utc>>,
#[serde(rename = "type")]
- version_type: Option<VersionType>,
+ pub version_type: Option<VersionType>,
- compatibility_rules: Option<Vec<CompatibilityRule>>, //
- incompatibility_reason: Option<String>, // message shown when compatibility rules fail for this version
+ pub compatibility_rules: Option<Vec<CompatibilityRule>>, //
+ pub incompatibility_reason: Option<String>, // message shown when compatibility rules fail for this version
- inherits_from: Option<String>
+ pub inherits_from: Option<String>
/* omitting field `savableVersion' because it seems like a vestigial part from old launcher versions
* (also it isn't even a string that is present in modern liblauncher.so, so I assume it will never be used.)
@@ -360,8 +316,6 @@ where
mod tests {
use std::fs;
- use serde_json::json;
-
use super::*;
#[test]
@@ -371,4 +325,12 @@ mod tests {
let arg: CompleteVersion = serde_json::from_str(s.unwrap().as_str()).unwrap();
dbg!(arg);
}
+
+ #[test]
+ fn test_it2() {
+ let s = fs::read_to_string("./test_stuff/version_manifest_v2.json");
+
+ let arg: VersionManifest = serde_json::from_str(s.unwrap().as_str()).unwrap();
+ dbg!(arg);
+ }
}