Cargo formatting

This commit is contained in:
kdeng00
2024-05-26 20:35:55 -04:00
parent a3c0565863
commit c0dc1eb78c
10 changed files with 44 additions and 56 deletions
+10 -12
View File
@@ -5,12 +5,10 @@ use crate::models;
// use super::syncer_base::Result;
pub struct RetrieveRecords {
pub api: models::api::API,
}
impl Default for RetrieveRecords {
fn default() -> Self {
RetrieveRecords {
@@ -19,31 +17,31 @@ impl Default for RetrieveRecords {
}
}
impl RetrieveRecords {
pub async fn get_all_songs(&self, token: &models::token::Token)
-> Result<Vec<models::song::Song>, Error> {
pub async fn get_all_songs(
&self,
token: &models::token::Token,
) -> Result<Vec<models::song::Song>, Error> {
let mut songs: Vec<models::song::Song> = Vec::new();
let url = self.retrieve_url();
let access_token = token.bearer_token();
let client = reqwest::Client::new();
let response = client.get(&url)
let response = client
.get(&url)
.header(reqwest::header::AUTHORIZATION, access_token)
.send()
.await
.unwrap();
match response.status() {
reqwest::StatusCode::OK => {
// on success, parse our JSON to an APIResponse
let s = response.json::<Vec<models::song::Song>>().await;
match s {
//
//
Ok(parsed) => {
songs = parsed;
},
}
Err(_) => println!("Hm, the response didn't match the shape we expected."),
};
}
@@ -54,7 +52,7 @@ impl RetrieveRecords {
panic!("Uh oh! Something unexpected happened: {:?}", other);
}
}
return Ok(songs);
}
@@ -71,4 +69,4 @@ impl RetrieveRecords {
return url;
}
}
}