aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2022-11-28 19:29:32 +0100
committerGitHub <noreply@github.com>2022-11-28 19:29:32 +0100
commit179474d2c2a09abaa8806b9da791121b6a5ca082 (patch)
tree5c311959e9ef20ee30b00eba6cc612911d9ff7d9
parentc52a78c2687a308187f6ee2fa3ff67486ac7d324 (diff)
downloadFlightCore-179474d2c2a09abaa8806b9da791121b6a5ca082.tar.gz
FlightCore-179474d2c2a09abaa8806b9da791121b6a5ca082.zip
style: Auto-format all Rust code (#84)
-rw-r--r--src-tauri/src/github/release_notes.rs23
-rw-r--r--src-tauri/src/lib.rs14
-rw-r--r--src-tauri/src/main.rs6
-rw-r--r--src-tauri/src/mod_management/mod.rs20
-rw-r--r--src-tauri/src/platform_specific/linux.rs4
-rw-r--r--src-tauri/src/platform_specific/mod.rs1
-rw-r--r--src-tauri/src/platform_specific/windows.rs1
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs5
8 files changed, 39 insertions, 35 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs
index f5389d77..69669244 100644
--- a/src-tauri/src/github/release_notes.rs
+++ b/src-tauri/src/github/release_notes.rs
@@ -1,11 +1,11 @@
-use std::vec::Vec;
use serde::{Deserialize, Serialize};
+use std::vec::Vec;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ReleaseInfo {
pub name: String,
pub published_at: String,
- pub body: String
+ pub body: String,
}
// Fetches repo release API and returns response as string
@@ -55,7 +55,6 @@ pub async fn check_is_flightcore_outdated() -> Result<bool, String> {
Ok(version != newest_release_version)
}
-
#[tauri::command]
pub async fn get_northstar_release_notes() -> Result<Vec<ReleaseInfo>, String> {
let url = "https://api.github.com/repos/R2Northstar/Northstar/releases";
@@ -65,20 +64,24 @@ pub async fn get_northstar_release_notes() -> Result<Vec<ReleaseInfo>, String> {
serde_json::from_str(&res).expect("JSON was not well-formatted");
println!("Done checking GitHub API");
- return Ok(
- json_response.iter().map(|release| ReleaseInfo {
- name: release.get("name")
+ return Ok(json_response
+ .iter()
+ .map(|release| ReleaseInfo {
+ name: release
+ .get("name")
.and_then(|value| value.as_str())
.unwrap()
.to_string(),
- published_at: release.get("published_at")
+ published_at: release
+ .get("published_at")
.and_then(|value| value.as_str())
.unwrap()
.to_string(),
- body: release.get("body")
+ body: release
+ .get("body")
.and_then(|value| value.as_str())
.unwrap()
.to_string(),
- }).collect()
- );
+ })
+ .collect());
}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index bfac47c7..4a817af9 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -220,9 +220,12 @@ pub async fn install_northstar(
.ok_or_else(|| panic!("Couldn't find Northstar on thunderstore???"))
.unwrap();
- do_install(nmod.versions.get(&nmod.latest).unwrap(), std::path::Path::new(game_path))
- .await
- .unwrap();
+ do_install(
+ nmod.versions.get(&nmod.latest).unwrap(),
+ std::path::Path::new(game_path),
+ )
+ .await
+ .unwrap();
Ok(nmod.latest.clone())
}
@@ -334,10 +337,7 @@ pub fn convert_release_candidate_number(version_number: String) -> String {
/// Returns a serde json object of the parsed `enabledmods.json` file
pub fn get_enabled_mods(game_install: GameInstall) -> Result<serde_json::value::Value, String> {
- let enabledmods_json_path = format!(
- "{}/R2Northstar/enabledmods.json",
- game_install.game_path
- );
+ let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);
// Check for JSON file
if !std::path::Path::new(&enabledmods_json_path).exists() {
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 8947d743..1f6fad44 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -12,10 +12,12 @@ use std::{
use app::*;
mod github;
-use github::release_notes::{get_northstar_release_notes, check_is_flightcore_outdated};
+use github::release_notes::{check_is_flightcore_outdated, get_northstar_release_notes};
mod repair_and_verify;
-use repair_and_verify::{clean_up_download_folder, disable_all_but_core, verify_game_files, get_log_list};
+use repair_and_verify::{
+ clean_up_download_folder, disable_all_but_core, get_log_list, verify_game_files,
+};
mod mod_management;
use mod_management::{
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index 09c01593..b8d210ff 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -5,8 +5,8 @@ use anyhow::{anyhow, Result};
use app::NorthstarMod;
use std::path::PathBuf;
-use app::GameInstall;
use app::get_enabled_mods;
+use app::GameInstall;
use json5;
@@ -82,7 +82,6 @@ pub fn set_mod_enabled_status(
Ok(())
}
-
/// Parses `mod.json` for mod name
// TODO: Maybe pass PathBuf or serde json object
fn parse_mod_json_for_mod_name(mod_json_path: String) -> Result<String, anyhow::Error> {
@@ -121,7 +120,9 @@ fn parse_mod_json_for_thunderstore_mod_string(
}
/// Parse `mods` folder for installed mods.
-fn parse_installed_mods(game_install: GameInstall) -> Result<Vec<(String, Option<String>)>, String> {
+fn parse_installed_mods(
+ game_install: GameInstall,
+) -> Result<Vec<(String, Option<String>)>, String> {
let ns_mods_folder = format!("{}/R2Northstar/mods/", game_install.game_path);
let paths = std::fs::read_dir(ns_mods_folder).unwrap();
@@ -204,7 +205,6 @@ pub fn get_installed_mods_and_properties(
}
async fn get_ns_mod_download_url(thunderstore_mod_string: String) -> Result<String, String> {
-
// TODO: This will crash the thread if not internet connection exist. `match` should be used instead
let index = thermite::api::get_package_index().await.unwrap().to_vec();
@@ -230,7 +230,6 @@ fn add_thunderstore_mod_string(
path_to_mod_json: String,
thunderstore_mod_string: String,
) -> Result<(), anyhow::Error> {
-
// Read file into string and parse it
let data = std::fs::read_to_string(path_to_mod_json.clone())?;
let parsed_json: serde_json::Value = json5::from_str(&data)?;
@@ -309,9 +308,8 @@ pub async fn fc_download_mod_and_install(
Err(err) => {
if err.to_string() == "Cannot install Northstar as a mod!" {
continue; // For Northstar as a dependency, we just skip it
- }
- else {
- return Err(err.to_string())
+ } else {
+ return Err(err.to_string());
}
}
};
@@ -319,7 +317,11 @@ pub async fn fc_download_mod_and_install(
// Prevent installing Northstar as a mod
// While it would fail during install anyway, having explicit error message is nicer
- let blacklisted_mods = ["northstar-Northstar", "northstar-NorthstarReleaseCandidate", "ebkr-r2modman"];
+ let blacklisted_mods = [
+ "northstar-Northstar",
+ "northstar-NorthstarReleaseCandidate",
+ "ebkr-r2modman",
+ ];
for blacklisted_mod in blacklisted_mods {
if thunderstore_mod_string.contains(blacklisted_mod) {
return Err("Cannot install Northstar as a mod!".to_string());
diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs
index a6d37f22..eb9fbea6 100644
--- a/src-tauri/src/platform_specific/linux.rs
+++ b/src-tauri/src/platform_specific/linux.rs
@@ -1,14 +1,14 @@
// Linux specific code
-use std::process::Command;
use regex::Regex;
+use std::process::Command;
pub fn check_glibc_v() -> f32 {
let out = Command::new("/bin/ldd")
.arg("--version")
.output()
.expect("failed to run 'ldd --version'");
-
+
// parse the output down to just the first line
let lddva = String::from_utf8_lossy(&out.stdout);
let lddvl: Vec<&str> = lddva.split('\n').collect();
diff --git a/src-tauri/src/platform_specific/mod.rs b/src-tauri/src/platform_specific/mod.rs
index 21cac9c2..ef45107e 100644
--- a/src-tauri/src/platform_specific/mod.rs
+++ b/src-tauri/src/platform_specific/mod.rs
@@ -2,4 +2,3 @@
pub mod windows;
pub mod linux;
-
diff --git a/src-tauri/src/platform_specific/windows.rs b/src-tauri/src/platform_specific/windows.rs
index 7627fe4f..2803bf05 100644
--- a/src-tauri/src/platform_specific/windows.rs
+++ b/src-tauri/src/platform_specific/windows.rs
@@ -1,5 +1,4 @@
/// Windows specific code
-
use powershell_script::PsScriptBuilder;
use regex::Regex;
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index 47ec4cc9..3d5fdc04 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -1,8 +1,7 @@
-/// Contains various functions to repair common issues and verifying installation
-
-use app::{get_enabled_mods, GameInstall};
use crate::{mod_management::set_mod_enabled_status, northstar::CORE_MODS};
use anyhow::anyhow;
+/// Contains various functions to repair common issues and verifying installation
+use app::{get_enabled_mods, GameInstall};
/// Verifies Titanfall2 game files
pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> {