From 3cde57dca839cfbeb6a495c11a3fc29f91369497 Mon Sep 17 00:00:00 2001 From: KD Date: Sun, 29 Jun 2025 17:33:45 -0400 Subject: [PATCH] Refactoring (#149) * Warning fixes * More warning fixes * Cargo.toml cleanup --- Cargo.toml | 2 -- src/callers/coverart.rs | 16 ++++++++-------- src/callers/metadata.rs | 8 ++++---- src/callers/song.rs | 24 ++++++++++++------------ src/main.rs | 2 +- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e5dc236..e3897bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,6 @@ tokio = { version = "1.45.1", features = ["full"] } tokio-util = { version = "0.7.15" } tower-http = { version = "0.6.6", features = ["timeout"] } tracing-subscriber = "0.3.19" -# mime = { version = "0.3.17" } -# mime_guess = { version = "2.0.5" } futures = { version = "0.3.31" } uuid = { version = "1.17.0", features = ["v4", "serde"] } sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio-native-tls", "time", "uuid"] } diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 79661f1..6a7bbc0 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -114,7 +114,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e:?}"); }); match result { @@ -163,7 +163,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e:?}"); }); match result { @@ -194,7 +194,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e:?}"); }); match result { @@ -225,7 +225,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e:?}"); }); match result { @@ -250,7 +250,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e}"); }); match result { @@ -275,7 +275,7 @@ pub mod db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error updating query: {:?}", e); + eprintln!("Error updating query: {e}"); }); match result { @@ -307,7 +307,7 @@ pub mod cov_db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -461,7 +461,7 @@ pub mod endpoint { // TODO: Make the conent disposition more dynamic headers.insert( axum::http::header::CONTENT_DISPOSITION, - format!("attachment; filename=\"{}.jpg\"", id) + format!("attachment; filename=\"{id}.jpg\"") .parse() .unwrap(), ); diff --git a/src/callers/metadata.rs b/src/callers/metadata.rs index 3a37dee..6825fbd 100644 --- a/src/callers/metadata.rs +++ b/src/callers/metadata.rs @@ -107,7 +107,7 @@ pub mod metadata_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -135,7 +135,7 @@ pub mod metadata_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -174,7 +174,7 @@ pub mod metadata_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -241,7 +241,7 @@ pub mod endpoint { match params.id { Some(id) => { - println!("Something works {:?}", id); + println!("Something works {id}"); match super::metadata_queue::get_with_id(&pool, &id).await { Ok(item) => { diff --git a/src/callers/song.rs b/src/callers/song.rs index 4d12454..d957ba9 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -189,7 +189,7 @@ pub mod song_db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting query: {:?}", e); + eprintln!("Error inserting query: {e}"); }); match result { @@ -223,7 +223,7 @@ pub mod song_db { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e}"); }); match result { @@ -339,7 +339,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -369,7 +369,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {:?}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -401,7 +401,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -436,7 +436,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error selecting: {:?}", e); + eprintln!("Error selecting: {e}"); }); match result { @@ -463,7 +463,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error updating record {:?}", e); + eprintln!("Error updating record {e}"); }); match result { @@ -488,7 +488,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error querying data: {:?}", e); + eprintln!("Error querying data: {e}"); }); match result { @@ -523,7 +523,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error updating record: {:?}", e); + eprintln!("Error updating record: {e}"); }); match result { @@ -546,7 +546,7 @@ mod song_queue { .fetch_one(pool) .await .map_err(|e| { - eprintln!("Error inserting: {}", e); + eprintln!("Error inserting: {e}"); }); match result { @@ -641,7 +641,7 @@ pub mod endpoint { axum::Extension(pool): axum::Extension, axum::extract::Path(id): axum::extract::Path, ) -> (StatusCode, axum::response::Response) { - println!("Id: {:?}", id); + println!("Id: {id}"); match song_queue::get_data(&pool, &id).await { Ok(data) => { @@ -654,7 +654,7 @@ pub mod endpoint { ); headers.insert( axum::http::header::CONTENT_DISPOSITION, - format!("attachment; filename=\"{}.flac\"", id) + format!("attachment; filename=\"{id}.flac\"") .parse() .unwrap(), ); diff --git a/src/main.rs b/src/main.rs index 450a5af..39b8000 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ pub mod db { pub async fn create_pool() -> Result { let database_url = icarus_envy::environment::get_db_url().await; - println!("Database url: {:?}", database_url); + println!("Database url: {database_url}"); PgPoolOptions::new() .max_connections(connection_settings::MAXCONN)