version manifest structs
This commit is contained in:
parent
9573df0f91
commit
6e11ab1052
3 changed files with 141 additions and 0 deletions
1
src-tauri/src/game/mod.rs
Normal file
1
src-tauri/src/game/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod version;
|
||||
139
src-tauri/src/game/version.rs
Normal file
139
src-tauri/src/game/version.rs
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AssetIndex {
|
||||
pub id: String,
|
||||
pub sha1: String,
|
||||
pub size: u64,
|
||||
pub total_size: u64,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct VersionDownload {
|
||||
pub sha1: String,
|
||||
pub size: u64,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct VersionDownloads {
|
||||
pub client: VersionDownload,
|
||||
pub server: VersionDownload,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct JavaVersion {
|
||||
pub major_version: u16,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RuleOS {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Rule {
|
||||
pub action: String,
|
||||
pub os: Option<RuleOS>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LibraryArtifact {
|
||||
pub path: String,
|
||||
pub sha1: String,
|
||||
pub size: u64,
|
||||
pub url: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LibraryDownloads {
|
||||
pub artifact: LibraryArtifact,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub classifiers: Option<HashMap<String, LibraryArtifact>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LibraryNatives {
|
||||
pub linux: Option<String>,
|
||||
pub osx: Option<String>,
|
||||
pub windows: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Library {
|
||||
pub downloads: LibraryDownloads,
|
||||
pub name: String,
|
||||
pub natives: Option<LibraryNatives>,
|
||||
pub rules: Option<Vec<Rule>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ArgumentRule {
|
||||
pub rules: Vec<Rule>,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(untagged)]
|
||||
pub enum Argument {
|
||||
String(String),
|
||||
Rule(ArgumentRule),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Arguments {
|
||||
pub game: Vec<Argument>,
|
||||
pub jvm: Vec<Argument>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ModernVersionManifest {
|
||||
pub asset_index: AssetIndex,
|
||||
pub downloads: VersionDownloads,
|
||||
pub id: String,
|
||||
pub java_version: JavaVersion,
|
||||
pub libraries: Vec<Library>,
|
||||
pub main_class: String,
|
||||
pub minecraft_arguments: String,
|
||||
pub release_time: String,
|
||||
|
||||
#[serde(rename = "type")]
|
||||
pub release_type: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct LegacyVersionManifest {
|
||||
pub asset_index: AssetIndex,
|
||||
pub downloads: VersionDownloads,
|
||||
pub id: String,
|
||||
pub java_version: JavaVersion,
|
||||
pub libraries: Vec<Library>,
|
||||
pub main_class: String,
|
||||
pub minecraft_arguments: String,
|
||||
pub release_time: String,
|
||||
|
||||
#[serde(rename = "type")]
|
||||
pub release_type: String,
|
||||
|
||||
// TODO
|
||||
// pub logging: Option<Logging>,
|
||||
}
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
#[allow(async_fn_in_trait)]
|
||||
pub mod auth;
|
||||
pub mod game;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue