From 75116d649e71e823183bb8d6cc6b4fd9e4d4b068 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 24 Jun 2026 14:40:03 -0400 Subject: [PATCH] Code formatting --- src/service/core.rs | 1 - src/service/mod.rs | 82 +++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/service/core.rs b/src/service/core.rs index b17f2e7..839e38f 100644 --- a/src/service/core.rs +++ b/src/service/core.rs @@ -27,4 +27,3 @@ impl Service { ); } } - diff --git a/src/service/mod.rs b/src/service/mod.rs index 20d0d85..d3bd740 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -1,6 +1,5 @@ pub mod core; - pub mod auth { pub struct Auth { pub app: crate::app::App, @@ -22,28 +21,27 @@ pub mod auth { println!("Payload: {payload:?}"); match client.post(api_url).json(&payload).send().await { - Ok(response) => { - match response.status() { - reqwest::StatusCode::OK => { - println!("Response: {response:?}"); - match response.text().await { - Ok(val) => { - match parse_token_response(&val).await { - Ok(login_result) => Ok(login_result), - Err(err) => Err(err) - } - } - Err(err) => Err(std::io::Error::other(err)), - } + Ok(response) => match response.status() { + reqwest::StatusCode::OK => { + println!("Response: {response:?}"); + match response.text().await { + Ok(val) => match parse_token_response(&val).await { + Ok(login_result) => Ok(login_result), + Err(err) => Err(err), + }, + Err(err) => Err(std::io::Error::other(err)), } - _ => Err(std::io::Error::other("Error getting token")), } - } + _ => Err(std::io::Error::other("Error getting token")), + }, Err(err) => Err(std::io::Error::other(err.to_string())), } } - pub async fn get_refresh_token(&self, login_result: &textsender_models::token::Login) -> Result { + pub async fn get_refresh_token( + &self, + login_result: &textsender_models::token::Login, + ) -> Result { let client = reqwest::Client::new(); let endpoint = String::from("api/v1/token/refresh"); let api_url = format!("{}/{endpoint}", self.app.auth_url); @@ -55,29 +53,27 @@ pub mod auth { }); match client.post(api_url).json(&payload).send().await { - Ok(response) => { - match response.status() { - reqwest::StatusCode::OK => { - println!("Response: {response:?}"); - match response.text().await { - Ok(val) => { - match parse_token_response(&val).await { - Ok(login_result) => Ok(login_result), - Err(err) => Err(err) - } - } - Err(err) => Err(std::io::Error::other(err)), - } + Ok(response) => match response.status() { + reqwest::StatusCode::OK => { + println!("Response: {response:?}"); + match response.text().await { + Ok(val) => match parse_token_response(&val).await { + Ok(login_result) => Ok(login_result), + Err(err) => Err(err), + }, + Err(err) => Err(std::io::Error::other(err)), } - _ => Err(std::io::Error::other("Error getting token")), } - } + _ => Err(std::io::Error::other("Error getting token")), + }, Err(err) => Err(std::io::Error::other(err.to_string())), } } } - async fn parse_token_response(response: &String) -> Result { + async fn parse_token_response( + response: &String, + ) -> Result { match serde_json::from_str::(response) { Ok(j) => { println!("Good"); @@ -89,22 +85,20 @@ pub mod auth { match j.get("data") { Some(serde_json::Value::Array(lrs)) => { if lrs.is_empty() { - Err(std::io::Error::other( - "Error response is empty", - )) + Err(std::io::Error::other("Error response is empty")) } else { let lr = lrs[0].clone(); - let ll: textsender_models::token::LoginResult = match serde_json::from_value(lr) { Ok(lr) => lr, - Err(err) => { - return Err(std::io::Error::other(err.to_string())); - } - }; + let ll: textsender_models::token::LoginResult = + match serde_json::from_value(lr) { + Ok(lr) => lr, + Err(err) => { + return Err(std::io::Error::other(err.to_string())); + } + }; Ok(ll) } } - _ => Err(std::io::Error::other( - "Error parsing response", - )), + _ => Err(std::io::Error::other("Error parsing response")), } } Err(err) => Err(std::io::Error::other(err.to_string())),