cargo fmt
catapult PR / Rustfmt (pull_request) Successful in 49s
catapult PR / Check (pull_request) Successful in 1m32s
catapult PR / Clippy (pull_request) Failing after 2m18s

This commit is contained in:
2026-06-22 17:43:55 -04:00
parent aaa20c8752
commit dd9d452576
3 changed files with 117 additions and 124 deletions
+2 -4
View File
@@ -16,9 +16,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("App: {app:?}"); println!("App: {app:?}");
let auth = catapult::service::auth::Auth { let auth = catapult::service::auth::Auth { app: app.clone() };
app: app.clone()
};
let token = match auth.get_token().await { let token = match auth.get_token().await {
Ok(token) => token, Ok(token) => token,
Err(err) => { Err(err) => {
@@ -32,7 +30,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut svc = catapult::service::Service { let mut svc = catapult::service::Service {
app: app.clone(), app: app.clone(),
token token,
}; };
loop { loop {
+14 -19
View File
@@ -1,6 +1,6 @@
pub struct Service { pub struct Service {
pub app: crate::app::App, pub app: crate::app::App,
pub token: textsender_models::token::Login pub token: textsender_models::token::Login,
} }
impl Service { impl Service {
@@ -30,7 +30,7 @@ impl Service {
pub mod auth { pub mod auth {
pub struct Auth { pub struct Auth {
pub app: crate::app::App pub app: crate::app::App,
} }
/* /*
@@ -63,7 +63,8 @@ pub mod auth {
println!("Payload: {payload:?}"); println!("Payload: {payload:?}");
match client.post(api_url).json(&payload).send().await { match client.post(api_url).json(&payload).send().await {
Ok(response) => match response.status() { Ok(response) => {
match response.status() {
reqwest::StatusCode::OK => { reqwest::StatusCode::OK => {
println!("Response: {response:?}"); println!("Response: {response:?}");
match response.text().await { match response.text().await {
@@ -79,7 +80,9 @@ pub mod auth {
match j.get("data") { match j.get("data") {
Some(serde_json::Value::Array(lrs)) => { Some(serde_json::Value::Array(lrs)) => {
if lrs.is_empty() { if lrs.is_empty() {
Err(std::io::Error::other("Error response is empty")) Err(std::io::Error::other(
"Error response is empty",
))
} else { } else {
let lr = lrs[0].clone(); let lr = lrs[0].clone();
let ll: textsender_models::token::LoginResult = match serde_json::from_value(lr) { Ok(lr) => lr, let ll: textsender_models::token::LoginResult = match serde_json::from_value(lr) { Ok(lr) => lr,
@@ -91,33 +94,25 @@ pub mod auth {
// Ok(textsender_models::token::LoginResult::default()) // Ok(textsender_models::token::LoginResult::default())
} }
} }
_ => { _ => Err(std::io::Error::other(
Err(std::io::Error::other("Error parsing response")) "Error parsing response",
)),
} }
} }
} Err(err) => Err(std::io::Error::other(err.to_string())),
Err(err) => {
Err(std::io::Error::other(err.to_string()))
} }
} }
} Err(err) => Err(std::io::Error::other(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(err) => Err(std::io::Error::other(err.to_string())),
Err(std::io::Error::other(err.to_string()))
} }
} }
} }
} }
}
/* /*
* *