diff options
| author | 2025-02-19 01:32:48 -0600 | |
|---|---|---|
| committer | 2025-02-19 01:32:48 -0600 | |
| commit | e47a3743068a1efad03c17c044e76840e352d88f (patch) | |
| tree | e43a305766f0e2eb6765d486081864fc0cf6e7d7 | |
| parent | add demo flag (diff) | |
lints
| -rw-r--r-- | ozone-cli/src/main.rs | 2 | ||||
| -rw-r--r-- | ozone/src/auth/types.rs | 12 | ||||
| -rw-r--r-- | ozone/src/launcher.rs | 8 | ||||
| -rw-r--r-- | ozone/src/launcher/download.rs | 9 | ||||
| -rw-r--r-- | ozone/src/launcher/runner.rs | 1 | ||||
| -rw-r--r-- | ozone/src/launcher/version.rs | 2 | ||||
| -rw-r--r-- | ozone/src/util.rs | 2 |
7 files changed, 23 insertions, 13 deletions
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index f346d8d..9e0cc68 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -3,7 +3,7 @@ mod cli; use std::error::Error; use std::path::Path; use std::process::ExitCode; -use log::{error, info, trace, LevelFilter}; +use log::{error, info, trace}; use clap::Parser; use ozone::launcher::{Instance, JavaRuntimeSetting, Launcher, Settings, ALT_CLIENT_ID, MAIN_CLIENT_ID}; use ozone::launcher::version::{VersionList, VersionResult}; diff --git a/ozone/src/auth/types.rs b/ozone/src/auth/types.rs index 3f75387..bd4e059 100644 --- a/ozone/src/auth/types.rs +++ b/ozone/src/auth/types.rs @@ -251,6 +251,14 @@ pub struct AccountStorage { selected_account: Option<String> } +pub struct AccountNotKeyed; + +impl Debug for AccountNotKeyed { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.write_str("a key could not be derived for the account") + } +} + impl AccountStorage { pub async fn load(path: impl AsRef<Path>) -> Result<AccountStorage, io::Error> { let contents = match tokio::fs::read_to_string(&path).await { @@ -268,8 +276,8 @@ impl AccountStorage { tokio::fs::write(&path, &contents).await } - pub fn add_account(&mut self, account: Account) -> Result<String, ()> { - let key = account.get_key().ok_or(())?; + pub fn add_account(&mut self, account: Account) -> Result<String, AccountNotKeyed> { + let key = account.get_key().ok_or(AccountNotKeyed)?; self.accounts.insert(key.clone(), account); Ok(key) diff --git a/ozone/src/launcher.rs b/ozone/src/launcher.rs index 84a7e5d..c658b79 100644 --- a/ozone/src/launcher.rs +++ b/ozone/src/launcher.rs @@ -213,8 +213,7 @@ struct LaunchInfo<'l> { resolution: Option<Resolution>, - account: &'l Account, - force_demo: bool + account: &'l Account } #[derive(Debug)] @@ -234,7 +233,7 @@ struct LaunchFeatureMatcher<'l> { force_demo: bool } -impl<'a> FeatureMatcher<'a> for LaunchFeatureMatcher<'_> { +impl FeatureMatcher<'_> for LaunchFeatureMatcher<'_> { fn matches(self, feature: &str) -> bool { match feature { "has_custom_resolution" => self.instance.resolution.is_some(), @@ -523,8 +522,7 @@ impl Launcher { resolution: instance.resolution, - account, - force_demo + account }; let Some(ref main_class) = ver.main_class else { diff --git a/ozone/src/launcher/download.rs b/ozone/src/launcher/download.rs index 19a7edc..6f0e317 100644 --- a/ozone/src/launcher/download.rs +++ b/ozone/src/launcher/download.rs @@ -170,17 +170,20 @@ impl VerifiedDownload { tally: 0 } } - + + #[allow(dead_code)] // these are my emotional support functions pub fn with_size(mut self, expect: usize) -> VerifiedDownload { self.expect_size = Some(expect); self } - + + #[allow(dead_code)] pub fn with_sha1(mut self, expect: Digest) -> VerifiedDownload { self.expect_sha1.replace(expect); self } - + + #[allow(dead_code)] pub fn get_url(&self) -> &str { &self.url } diff --git a/ozone/src/launcher/runner.rs b/ozone/src/launcher/runner.rs index 23c0548..0d42bd3 100644 --- a/ozone/src/launcher/runner.rs +++ b/ozone/src/launcher/runner.rs @@ -187,6 +187,7 @@ use self::macos::*; #[cfg(not(any(target_os = "windows", target_os = "linux", target_os = "macos")))] use self::unknown::*; +#[allow(clippy::assertions_on_constants)] fn search_java_sync(base: impl AsRef<Path>, jni: bool) -> Result<Option<PathBuf>, io::Error> { assert!(JRE_PLATFORM_KNOWN); let search_path = Path::new(match jni { diff --git a/ozone/src/launcher/version.rs b/ozone/src/launcher/version.rs index 83e6100..7f7ee64 100644 --- a/ozone/src/launcher/version.rs +++ b/ozone/src/launcher/version.rs @@ -1,7 +1,7 @@ use std::{collections::{BTreeMap, HashMap}, error::Error, io::ErrorKind}; use std::borrow::Cow; use std::collections::HashSet; -use std::fmt::{Display, Write}; +use std::fmt::Display; use std::path::{Path, PathBuf}; use chrono::{DateTime, TimeDelta, Utc}; use log::{debug, info, warn}; diff --git a/ozone/src/util.rs b/ozone/src/util.rs index 5d7c2b3..48e0abc 100644 --- a/ozone/src/util.rs +++ b/ozone/src/util.rs @@ -275,7 +275,7 @@ pub fn check_path(name: &str) -> Result<&Path, &'static str> { Component::Prefix(_) | Component::RootDir => return Err("root path component in entry"), Component::ParentDir => depth.checked_sub(1) - .map_or_else(|| Err("entry path escapes"), |s| Ok(s))?, + .map_or_else(|| Err("entry path escapes"), Ok)?, Component::Normal(_) => depth + 1, _ => depth } |
