From 202a7e5224b2638cde8218ab4fa89b1f22e05c6b Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 2 Feb 2025 21:01:54 -0800 Subject: [PATCH] cargo fmt --- src/main.rs | 2 +- src/poll.rs | 7 +++---- src/user.rs | 26 ++++++++++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index d1fdd9f..e9eb4ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ mod user; use rocket::fs::FileServer; use rocket::response::Redirect; -use rocket_db_pools::{sqlx, Database, Connection}; +use rocket_db_pools::{sqlx, Connection, Database}; use rocket_dyn_templates::{context, Template}; use user::AuthenticatedUser; diff --git a/src/poll.rs b/src/poll.rs index 328f7a8..c55548c 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,9 +1,9 @@ +use crate::user::AuthenticatedUser; use crate::{feed_utils::fetch_feed, Db}; use rocket::http::Status; use rocket::serde::uuid::Uuid; use rocket::serde::{json::Json, Serialize}; use rocket_db_pools::Connection; -use crate::user::AuthenticatedUser; #[derive(Debug, Serialize)] #[serde(crate = "rocket::serde")] @@ -15,7 +15,7 @@ pub struct FeedPollResponse { pub async fn poll_feed( mut db: Connection, feed_id: Uuid, - user: AuthenticatedUser + user: AuthenticatedUser, ) -> Result, Status> { let feed_id = feed_id.to_string(); let user_id = user.user_id.to_string(); @@ -32,8 +32,7 @@ pub async fn poll_feed( .url; // Parse the URL - let url = url::Url::parse(&feed_url) - .map_err(|_| Status::InternalServerError)?; + let url = url::Url::parse(&feed_url).map_err(|_| Status::InternalServerError)?; let feed_data = fetch_feed(&url).await.map_err(|_| Status::BadGateway)?; diff --git a/src/user.rs b/src/user.rs index 85b0f44..cdb83dc 100644 --- a/src/user.rs +++ b/src/user.rs @@ -279,7 +279,10 @@ pub async fn setup_page(mut db: Connection) -> Result { } #[post("/setup", data = "")] -pub async fn setup(mut db: Connection, new_user: Json) -> Result> { +pub async fn setup( + mut db: Connection, + new_user: Json, +) -> Result> { // Check if any users exist let count = sqlx::query!("SELECT COUNT(*) as count FROM users") .fetch_one(&mut **db) @@ -299,12 +302,13 @@ pub async fn setup(mut db: Connection, new_user: Json) -> Result, new_user: Json) -> Result { eprintln!("Database error: {}", e); match e { - sqlx::Error::Database(db_err) if db_err.is_unique_violation() => Err(Json(SetupError { - error: "Username already exists".to_string(), - })), + sqlx::Error::Database(db_err) if db_err.is_unique_violation() => { + Err(Json(SetupError { + error: "Username already exists".to_string(), + })) + } _ => Err(Json(SetupError { error: "Failed to create user".to_string(), })),