From 0c58a6e8375ae9f2bc14895e00334bd4b51a6c61 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 1 May 2025 21:57:27 -0400 Subject: [PATCH] Code formatting --- src/callers/coverart.rs | 59 +++++++++++++++++++---------------------- src/main.rs | 20 ++++++++------ 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 083bbd7..15de43a 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -9,10 +9,7 @@ pub mod response { mod db { use sqlx::Row; - pub async fn insert( - pool: &sqlx::PgPool, - data: &Vec, - ) -> Result { + pub async fn insert(pool: &sqlx::PgPool, data: &Vec) -> Result { let result = sqlx::query( r#" INSERT INTO "coverartQueue" (data) VALUES($1) RETURNING id; @@ -50,38 +47,36 @@ pub mod endpoint { match multipart.next_field().await { Ok(Some(field)) => { - let name = field.name().unwrap().to_string(); - let file_name = field.file_name().unwrap().to_string(); - let content_type = field.content_type().unwrap().to_string(); - let data = field.bytes().await.unwrap(); - let raw_data = data.to_vec(); + let name = field.name().unwrap().to_string(); + let file_name = field.file_name().unwrap().to_string(); + let content_type = field.content_type().unwrap().to_string(); + let data = field.bytes().await.unwrap(); + let raw_data = data.to_vec(); - println!( - "Received file '{}' (name = '{}', content-type = '{}', size = {})", - file_name, - name, - content_type, - data.len() - ); + println!( + "Received file '{}' (name = '{}', content-type = '{}', size = {})", + file_name, + name, + content_type, + data.len() + ); - match super::db::insert(&pool, &raw_data).await { - Ok(id) => { - response.message = String::from("Successful"); - response.data.push(id); - (axum::http::StatusCode::OK, axum::Json(response)) - } - Err(err) => { - response.message = err.to_string(); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) - } - } - } - Ok(None) => { - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + match super::db::insert(&pool, &raw_data).await { + Ok(id) => { + response.message = String::from("Successful"); + response.data.push(id); + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + } } + Ok(None) => (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)), Err(err) => { - response.message = err.to_string(); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) } } } diff --git a/src/main.rs b/src/main.rs index a83d1e5..d7ff00c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -622,14 +622,18 @@ mod tests { let body = MultipartBody::from(form); // Send request - match app.clone().oneshot( - axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::endpoints::QUEUECOVERART) - .header(axum::http::header::CONTENT_TYPE, content_type) - .body(axum::body::Body::from_stream(body)) - .unwrap() - ).await { + match app + .clone() + .oneshot( + axum::http::Request::builder() + .method(axum::http::Method::POST) + .uri(crate::callers::endpoints::QUEUECOVERART) + .header(axum::http::header::CONTENT_TYPE, content_type) + .body(axum::body::Body::from_stream(body)) + .unwrap(), + ) + .await + { Ok(response) => { let resp = get_resp_data::(response).await;