Skip to content

Commit

Permalink
Fix all clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alisinabh committed May 8, 2024
1 parent 981df0c commit 04812da
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ unsafe_code = "forbid"
enum_glob_use = "deny"
uninlined-format-args = "warn"
needless-pass-by-value = "warn"
single-match-else = "warn"
wildcard-imports = "warn"
4 changes: 2 additions & 2 deletions src/db_refresher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ pub fn start_db_update_daemon(data: web::Data<impl UpdatableDB + 'static>, inter
let duration = match data.update_db(interval).await {
Ok(_) => success_update_sleep,
Err(error) => {
println!("Failed to update database {:?}", error);
println!("Failed to update database {error:?}");
failure_update_sleep
}
};

println!("Updater sleeping for {:?}", duration);
println!("Updater sleeping for {duration:?}");
sleep(duration).await;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/download_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct AlreadyDownloaded;

impl fmt::Display for AlreadyDownloaded {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
write!(f, "{self:?}")
}
}

Expand Down Expand Up @@ -94,7 +94,7 @@ pub async fn extract_db(path: &str, filename: &str) -> Result<String, Box<dyn Er
let output = command.arg("*.mmdb").output().await?;

if !output.status.success() {
println!("{:?}", output);
println!("{output:?}");
return Err("failed to extract archive".into());
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn init_db(db_path: &str, db_variant: &str) -> web::Data<MaxmindDB> {
}

pub fn start_db_refresher(maxmind_db_arc: web::Data<MaxmindDB>, update_interval: u64) {
db_refresher::start_db_update_daemon(maxmind_db_arc.clone(), update_interval)
db_refresher::start_db_update_daemon(maxmind_db_arc, update_interval)
}

pub async fn start_server(
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() -> Result<()> {
}
Some(command) => Err(Error::new(
ErrorKind::InvalidInput,
format!("Invalid command: {}", command),
format!("Invalid command: {command}"),
)),
}
}
7 changes: 5 additions & 2 deletions src/maxmind_db.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::{db_refresher::UpdatableDB, download_utils::*};
use crate::{
db_refresher::UpdatableDB,
download_utils::{download_with_basic_auth, extract_db, AlreadyDownloaded},
};
use maxminddb::{MaxMindDBError, Reader};
use serde::Deserialize;
use std::{
Expand Down Expand Up @@ -144,7 +147,7 @@ impl<'de> MaxmindDBInner {
let filename = path.file_name().unwrap().to_str().unwrap().to_string();
let full_path = path.to_str().unwrap().to_string();

println!("Loading database from {}", full_path);
println!("Loading database from {full_path}");
let reader = Reader::open_readfile(&full_path)?;

Ok(Self {
Expand Down
5 changes: 2 additions & 3 deletions src/services/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn handle(data: web::Data<MaxmindDB>, path: web::Path<(String, String)>) -
.map(|ip_address| {
ip_address.parse().map_err(|_| {
bad_request(
format!("Invalid IP Address {:?}", ip_address),
format!("Invalid IP Address {ip_address:?}"),
"INVALID_IP".to_string(),
)
})
Expand All @@ -81,8 +81,7 @@ async fn handle(data: web::Data<MaxmindDB>, path: web::Path<(String, String)>) -
if ip.is_special_ip() {
Err(bad_request(
format!(
"IP Address is part of a special list and not allowed: {}",
ip
"IP Address is part of a special list and not allowed: {ip}"
),
"SPECIAL_IP".to_string(),
))
Expand Down
2 changes: 1 addition & 1 deletion tests/lookup_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async fn test_rejects_too_many_ips() {
let (service, _app_data) = setup().await;

let ip_addresses = (1..=51)
.map(|i| format!("1.1.1.{}", i))
.map(|i| format!("1.1.1.{i}"))
.collect::<Vec<_>>()
.join(",");

Expand Down

0 comments on commit 04812da

Please sign in to comment.