Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fmt #11

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/common/src/env/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

60 changes: 30 additions & 30 deletions crates/common/src/jre/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ use {

#[derive(Debug, Deserialize, PartialEq, Eq, Hash)]
pub enum Target {
#[serde(rename = "gamecore")]
GameCore,
#[serde(rename = "linux")]
Linux,
#[serde(rename = "linux-i386")]
LinuxI386,
#[serde(rename = "mac-os")]
Macos,
#[serde(rename = "mac-os-arm64")]
MacosArm64,
#[serde(rename = "windows-arm64")]
WindowsArm64,
#[serde(rename = "windows-x64")]
WindowsX64,
#[serde(rename = "windows-x86")]
WindowsX86,
#[serde(rename = "gamecore")]
GameCore,
#[serde(rename = "linux")]
Linux,
#[serde(rename = "linux-i386")]
LinuxI386,
#[serde(rename = "mac-os")]
Macos,
#[serde(rename = "mac-os-arm64")]
MacosArm64,
#[serde(rename = "windows-arm64")]
WindowsArm64,
#[serde(rename = "windows-x64")]
WindowsX64,
#[serde(rename = "windows-x86")]
WindowsX86,
}

#[derive(Debug, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "kebab-case")]
pub enum ComponentType {
JavaRuntimeAlpha,
JavaRuntimeBeta,
JavaRuntimeGamma,
JavaRuntimeGammaSnapshot,
JavaRuntimeAlpha,
JavaRuntimeBeta,
JavaRuntimeGamma,
JavaRuntimeGammaSnapshot,
JreLegacy,
MinecraftJavaExe,
}
Expand All @@ -51,28 +51,28 @@ impl ComponentType {

#[derive(Debug, Deserialize)]
pub struct Manifest {
pub sha1: String,
pub size: u32,
pub url: String,
pub sha1: String,
pub size: u32,
pub url: String,
}

#[derive(Debug, Deserialize)]
pub struct Availability {
pub group: u32,
pub progress: u32,
pub group: u32,
pub progress: u32,
}

#[derive(Debug, Deserialize)]
pub struct Version {
pub name: String,
pub released: String,
pub name: String,
pub released: String,
}

#[derive(Debug, Deserialize)]
pub struct Component {
pub availability: Availability,
pub manifest: Manifest,
pub version: Version,
pub availability: Availability,
pub manifest: Manifest,
pub version: Version,
}

pub type JavaRuntime = HashMap<Target, HashMap<ComponentType, Vec<Component>>>;
34 changes: 17 additions & 17 deletions crates/common/src/jre/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
use url::Url;
use {
serde::Deserialize,
std::{
collections::HashMap,
path::PathBuf,
},
serde::Deserialize,
std::{
collections::HashMap,
path::PathBuf,
},
url::Url,
};

#[derive(Debug, Deserialize)]
pub struct File {
pub sha1: String,
pub size: u64,
pub url: Url,
pub sha1: String,
pub size: u64,
pub url: Url,
}

#[derive(Debug, Deserialize)]
pub struct Downloads {
pub lzma: Option<File>,
pub raw: File,
pub lzma: Option<File>,
pub raw: File,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum Entry {
Link,
Directory,
File {
executable: bool,
downloads: Downloads,
},
Directory,
File {
executable: bool,
downloads: Downloads,
},
}

pub type Files = HashMap<PathBuf, Entry>;

#[derive(Debug, Deserialize)]
pub struct Manifest {
pub files: Files,
pub files: Files,
}
4 changes: 2 additions & 2 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod manifest;
pub mod jre;
pub mod env;
pub mod jre;
pub mod libutils;
pub mod manifest;
42 changes: 21 additions & 21 deletions crates/common/src/libutils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
use {
regex::Regex,
std::{
iter,
path::PathBuf,
},
regex::Regex,
std::{
iter,
path::PathBuf,
},
};

pub fn libname_to_path(name: &str) -> Option<PathBuf> {
let re = Regex::new(r"^([^:]+):([^:]+):(.+)").unwrap();
let re = Regex::new(r"^([^:]+):([^:]+):(.+)").unwrap();

let ca = match re.captures(name) {
Some(it) => it,
None => return None,
};
let ca = match re.captures(name) {
Some(it) => it,
None => return None,
};

let package = &ca[0];
let artifact = &ca[1];
let version = &ca[2];
let package = &ca[0];
let artifact = &ca[1];
let version = &ca[2];

let sub = format!("{}-{}.jar", artifact, version);
let sub = format!("{}-{}.jar", artifact, version);

Some(PathBuf::from_iter(
package
.split('.')
.chain(iter::once(artifact))
.chain(iter::once(version))
.chain(iter::once(sub.as_str())),
))
Some(PathBuf::from_iter(
package
.split('.')
.chain(iter::once(artifact))
.chain(iter::once(version))
.chain(iter::once(sub.as_str())),
))
}
Loading