Update dependencies #53

Merged
kdeng00 merged 11 commits from update_dependencies into icarus_v2_support 2025-07-02 12:26:38 -04:00
6 changed files with 17 additions and 104 deletions
Showing only changes of commit 53ca7702cf - Show all commits
-18
View File
@@ -9,30 +9,12 @@ pub fn retrieve_url(api: &models::api::API, with_id: bool, id: &uuid::Uuid) -> S
} }
fn retrieve_url_reg(api: &models::api::API) -> String { fn retrieve_url_reg(api: &models::api::API) -> String {
/*
let mut url: String = String::from(&api.url);
url += &String::from("/");
url += &String::from("api/");
url += &String::from(&api.version);
url += &String::from("/");
url += &String::from(&api.endpoint);
url += &String::from("/");
*/
let url = format!("{}/api/{}/{}/", api.url, api.version, api.endpoint); let url = format!("{}/api/{}/{}/", api.url, api.version, api.endpoint);
url url
} }
fn retrieve_url_with_id(api: &models::api::API, id: &uuid::Uuid) -> String { fn retrieve_url_with_id(api: &models::api::API, id: &uuid::Uuid) -> String {
/*
let mut url: String = String::from(&api.url);
url += &String::from("api/");
url += &String::from(&api.version);
url += &String::from("/");
url += &String::from(&api.endpoint);
url += &String::from("/");
url += &id.to_string();
*/
let url = format!("{}/api/{}/{}/{}", api.url, api.version, api.endpoint, id); let url = format!("{}/api/{}/{}/{}", api.url, api.version, api.endpoint, id);
url url
+2 -16
View File
@@ -10,16 +10,6 @@ pub struct Delete {
pub api: models::api::API, pub api: models::api::API,
} }
/*
impl Default for Delete {
fn default() -> Self {
Delete {
api: models::api::API::default(),
}
}
}
*/
impl Delete { impl Delete {
pub async fn delete_song( pub async fn delete_song(
&mut self, &mut self,
@@ -43,14 +33,10 @@ impl Delete {
match response.json::<icarus_models::song::Song>().await { match response.json::<icarus_models::song::Song>().await {
Ok(sng) => Ok(sng), Ok(sng) => Ok(sng),
Err(er) => Err(std::io::Error::other( Err(er) => Err(std::io::Error::other(er.to_string())),
er.to_string(),
)),
} }
} }
other => Err(std::io::Error::other( other => Err(std::io::Error::other(other.to_string())),
other.to_string(),
)),
} }
} }
} }
+4 -22
View File
@@ -8,16 +8,6 @@ pub struct Download {
pub api: models::api::API, pub api: models::api::API,
} }
/*
impl Default for Download {
fn default() -> Self {
Download {
api: models::api::API::default(),
}
}
}
*/
#[derive(Debug)] #[derive(Debug)]
pub enum MyError { pub enum MyError {
Request(reqwest::Error), Request(reqwest::Error),
@@ -48,24 +38,16 @@ impl Download {
reqwest::StatusCode::OK => { reqwest::StatusCode::OK => {
let data = rep.text(); let data = rep.text();
match data.await { match data.await {
Ok(e) => { Ok(e) => Ok(e),
Ok(e) Err(er) => Err(MyError::Other(er.to_string())),
}
Err(er) => {
Err(MyError::Other(er.to_string()))
}
} }
} }
reqwest::StatusCode::UNAUTHORIZED => { reqwest::StatusCode::UNAUTHORIZED => {
Err(MyError::Other(String::from("Need to grab a new token"))) Err(MyError::Other(String::from("Need to grab a new token")))
} }
other => { other => Err(MyError::Other(other.to_string())),
Err(MyError::Other(other.to_string()))
}
}, },
Err(er) => { Err(er) => Err(MyError::Request(er)),
Err(MyError::Request(er))
}
} }
} }
} }
+3 -23
View File
@@ -9,16 +9,6 @@ pub struct RetrieveRecords {
pub api: models::api::API, pub api: models::api::API,
} }
/*
impl Default for RetrieveRecords {
fn default() -> Self {
RetrieveRecords {
api: models::api::API::default(),
}
}
}
*/
impl RetrieveRecords { impl RetrieveRecords {
pub async fn get_all_songs( pub async fn get_all_songs(
&mut self, &mut self,
@@ -41,23 +31,13 @@ impl RetrieveRecords {
// on success, parse our JSON to an APIResponse // on success, parse our JSON to an APIResponse
match response.json::<Vec<icarus_models::song::Song>>().await { match response.json::<Vec<icarus_models::song::Song>>().await {
Ok(parsed) => Ok(parsed), Ok(parsed) => Ok(parsed),
Err(err) => { Err(err) => Err(std::io::Error::other(err.to_string())),
Err(std::io::Error::other(
err.to_string(),
))
}
} }
} }
reqwest::StatusCode::UNAUTHORIZED => { reqwest::StatusCode::UNAUTHORIZED => {
Err(std::io::Error::other( Err(std::io::Error::other("Need to grab a new token"))
"Need to grab a new token",
))
}
other => {
Err(std::io::Error::other(
other.to_string(),
))
} }
other => Err(std::io::Error::other(other.to_string())),
} }
} }
} }
+7 -22
View File
@@ -11,16 +11,6 @@ pub struct Upload {
pub api: models::api::API, pub api: models::api::API,
} }
/*
impl Default for Upload {
fn default() -> Self {
Upload {
api: models::api::API::default(),
}
}
}
*/
impl Upload { impl Upload {
pub async fn upload_song_with_metadata( pub async fn upload_song_with_metadata(
&mut self, &mut self,
@@ -56,12 +46,8 @@ impl Upload {
.send() .send()
.await .await
{ {
Ok(r) => { Ok(r) => Ok(r),
Ok(r) Err(err) => Err(err),
}
Err(err) => {
Err(err)
}
} }
} }
@@ -74,11 +60,6 @@ impl Upload {
let coverpath = cover.path.clone(); let coverpath = cover.path.clone();
println!("Cover path: {coverpath:?}"); println!("Cover path: {coverpath:?}");
let song_detail = song.to_metadata_json(true).unwrap_or_default(); let song_detail = song.to_metadata_json(true).unwrap_or_default();
/*{
Ok(s) => s,
Err(_) => String::new(),
};
*/
println!("\n{song_detail}\n"); println!("\n{song_detail}\n");
@@ -102,7 +83,11 @@ impl Upload {
} }
pub fn set_api(&mut self, host: &str) { pub fn set_api(&mut self, host: &str) {
let api = models::api::API { url: host.to_owned(), version: String::from("v1"), endpoint: String::new() }; let api = models::api::API {
url: host.to_owned(),
version: String::from("v1"),
endpoint: String::new(),
};
self.api = api; self.api = api;
} }
} }
+1 -3
View File
@@ -1,8 +1,6 @@
pub fn o_to_string(val: &std::ffi::OsString) -> Result<std::string::String, std::io::Error> { pub fn o_to_string(val: &std::ffi::OsString) -> Result<std::string::String, std::io::Error> {
match val.clone().into_string() { match val.clone().into_string() {
Ok(value) => Ok(value), Ok(value) => Ok(value),
Err(_) => Err(std::io::Error::other( Err(_) => Err(std::io::Error::other(String::from("Error"))),
String::from("Error"),
)),
} }
} }