Skip to content

Commit

Permalink
fix: clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Jan 14, 2025
1 parent 6468f1e commit 2e31c96
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
4 changes: 2 additions & 2 deletions examples/src/bin/auth_azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use xal::{
use xal_examples::auth_main;

// Replace with your own Azure Client parameters
const CLIENT_ID: &'static str = "388ea51c-0b25-4029-aae2-17df49d23905";
const REDIRECT_URL: &'static str = "http://localhost:8080/auth/callback";
const CLIENT_ID: &str = "388ea51c-0b25-4029-aae2-17df49d23905";
const REDIRECT_URL: &str = "http://localhost:8080/auth/callback";
const CLIENT_SECRET: Option<&'static str> = None;

pub struct HttpCallbackHandler {
Expand Down
16 changes: 8 additions & 8 deletions examples/src/bin/auth_titlehub.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Download savegames for a specific title
//!
use std::collections::HashMap;
use std::{collections::HashMap, path::Path};
use std::io::Write;
use std::path::PathBuf;

Expand Down Expand Up @@ -52,8 +52,8 @@ pub struct SavegameAtoms {
}

// Replace with your own Azure Client parameters
const CLIENT_ID: &'static str = "388ea51c-0b25-4029-aae2-17df49d23905";
const REDIRECT_URL: &'static str = "http://localhost:8080/auth/callback";
const CLIENT_ID: &str = "388ea51c-0b25-4029-aae2-17df49d23905";
const REDIRECT_URL: &str = "http://localhost:8080/auth/callback";
const CLIENT_SECRET: Option<&'static str> = None;

pub struct HttpCallbackHandler {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl AuthPromptCallback for HttpCallbackHandler {
}
}

pub fn assemble_filepath(root_path: &PathBuf, atom_type: &str, path: &str) -> PathBuf {
pub fn assemble_filepath(root_path: &Path, atom_type: &str, path: &str) -> PathBuf {
let modified_path = {
let tmp = path
// Replace separator with platform-specific separator
Expand All @@ -107,9 +107,9 @@ pub fn assemble_filepath(root_path: &PathBuf, atom_type: &str, path: &str) -> Pa
.replace("X", ".")
.replace("E", "-");

if tmp.starts_with(std::path::MAIN_SEPARATOR_STR) {
if let Some(stripped) = tmp.strip_prefix(std::path::MAIN_SEPARATOR_STR) {
// Remove leading path seperator
tmp[1..].to_string()
stripped.to_string()
}
else {
tmp
Expand Down Expand Up @@ -173,7 +173,7 @@ async fn main() -> Result<(), Error> {
let scid = "05c20100-6e60-45d5-878a-4903149e11ae";

let mut target_dir = PathBuf::new();
target_dir.push(&pfn);
target_dir.push(pfn);
target_dir.push(&xuid);

if !target_dir.exists() {
Expand Down Expand Up @@ -248,7 +248,7 @@ async fn main() -> Result<(), Error> {

if let Some(parent) = filepath.parent() {
if !parent.exists() {
std::fs::create_dir_all(&parent)?;
std::fs::create_dir_all(parent)?;
}
}

Expand Down
20 changes: 5 additions & 15 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,9 +943,7 @@ impl XalAuthenticator {
.send()
.await?
.json_ex::<response::SisuAuthorizationResponse>()
.await
.map_err(std::convert::Into::into)
}
.await}

/// Requests a Xbox Live Device Token from the Xbox Live authentication service.
///
Expand Down Expand Up @@ -1013,9 +1011,7 @@ impl XalAuthenticator {
.send()
.await?
.json_ex::<response::DeviceToken>()
.await
.map_err(std::convert::Into::into)
}
.await}

/// Retrieves a Xbox User Token for a specified Access Token.
///
Expand Down Expand Up @@ -1090,9 +1086,7 @@ impl XalAuthenticator {
.log()
.await?
.json_ex::<response::UserToken>()
.await
.map_err(std::convert::Into::into)
}
.await}

/// Retrieves a Title Token for a specified Access Token and Device Token.
///
Expand Down Expand Up @@ -1170,9 +1164,7 @@ impl XalAuthenticator {
.log()
.await?
.json_ex::<response::TitleToken>()
.await
.map_err(std::convert::Into::into)
}
.await}

/// Authenticates with the Xbox Live service and retrieves an XSTS token.
///
Expand Down Expand Up @@ -1275,9 +1267,7 @@ impl XalAuthenticator {
.log()
.await?
.json_ex::<response::XSTSToken>()
.await
.map_err(std::convert::Into::into)
}
.await}
}

#[cfg(test)]
Expand Down
4 changes: 1 addition & 3 deletions src/request_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@ impl RequestSigner {
&request.authorization,
&request.body,
max_body_bytes,
)
.map_err(std::convert::Into::into)
}
)}

/// Create signature from low-level parts
#[allow(clippy::too_many_arguments)]
Expand Down

0 comments on commit 2e31c96

Please sign in to comment.