Warning fixes (#54)

* More warning fixes

* Should be the last of the warning fixes

* Code cleanup

* Code formatting
This commit was merged in pull request #54.
This commit is contained in:
KD
2025-07-02 19:25:08 -04:00
committed by GitHub
parent 8b2b2f82e9
commit dbcfcfa109
14 changed files with 135 additions and 217 deletions
+9 -11
View File
@@ -4,19 +4,19 @@ use crate::models;
pub struct TokenManager {
pub user: icarus_models::user::User,
pub api: models::api::API,
pub api: models::api::Api,
}
impl Default for TokenManager {
fn default() -> Self {
let mut token = TokenManager {
user: icarus_models::user::User::default(),
api: models::api::API::default(),
api: models::api::Api::default(),
};
token.init();
return token;
token
}
}
@@ -26,7 +26,7 @@ impl TokenManager {
let url = self.retrieve_url();
println!("URL: {}", url);
println!("URL: {url}");
let mut token = icarus_models::token::AccessToken {
user_id: uuid::Uuid::nil(),
@@ -43,9 +43,7 @@ impl TokenManager {
match response.status() {
reqwest::StatusCode::OK => {
// on success, parse our JSON to an APIResponse
let s = response.json::<icarus_models::token::AccessToken>().await;
match s {
//
match response.json::<icarus_models::token::AccessToken>().await {
Ok(parsed) => {
token = parsed;
}
@@ -56,17 +54,17 @@ impl TokenManager {
println!("Need to grab a new token");
}
other => {
panic!("Uh oh! Something unexpected happened: {:?}", other);
panic!("Uh oh! Something unexpected happened: {other:?}");
}
}
return Ok(token);
Ok(token)
}
pub fn init(&mut self) {
let api = &mut self.api;
api.version = String::from("v1");
api.endpoint = String::from(format!("api/{}/login", api.version));
api.endpoint = format!("api/{}/login", api.version);
}
pub fn retrieve_url(&self) -> String {
@@ -74,6 +72,6 @@ impl TokenManager {
let mut url = String::from(&api.url);
url += &String::from(&api.endpoint);
return url;
url
}
}