diff --git a/Cargo.toml b/Cargo.toml index 1d3c661..0f245c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/db_refresher.rs b/src/db_refresher.rs index 35fd80c..2d0f97a 100644 --- a/src/db_refresher.rs +++ b/src/db_refresher.rs @@ -21,12 +21,12 @@ pub fn start_db_update_daemon(data: web::Data, 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; } }); diff --git a/src/download_utils.rs b/src/download_utils.rs index 6d66921..659740d 100644 --- a/src/download_utils.rs +++ b/src/download_utils.rs @@ -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:?}") } } @@ -94,7 +94,7 @@ pub async fn extract_db(path: &str, filename: &str) -> Result web::Data { } pub fn start_db_refresher(maxmind_db_arc: web::Data, 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( diff --git a/src/main.rs b/src/main.rs index f8a134b..7b01d2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,7 +61,7 @@ async fn main() -> Result<()> { } Some(command) => Err(Error::new( ErrorKind::InvalidInput, - format!("Invalid command: {}", command), + format!("Invalid command: {command}"), )), } } diff --git a/src/maxmind_db.rs b/src/maxmind_db.rs index f68663a..cb11649 100644 --- a/src/maxmind_db.rs +++ b/src/maxmind_db.rs @@ -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::{ @@ -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 { diff --git a/src/services/lookup.rs b/src/services/lookup.rs index 6fa359d..d937080 100644 --- a/src/services/lookup.rs +++ b/src/services/lookup.rs @@ -57,7 +57,7 @@ async fn handle(data: web::Data, 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(), ) }) @@ -81,8 +81,7 @@ async fn handle(data: web::Data, 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(), )) diff --git a/tests/lookup_service.rs b/tests/lookup_service.rs index 577ecd8..ca72ae6 100644 --- a/tests/lookup_service.rs +++ b/tests/lookup_service.rs @@ -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::>() .join(",");