cargo fmt

This commit is contained in:
kdeng00
2024-06-02 16:11:43 -04:00
parent ffc0d398f0
commit 9c3d5d67c5
3 changed files with 36 additions and 32 deletions
+14 -11
View File
@@ -21,7 +21,6 @@ pub struct CommitManager {
pub ica_action: models::icarus_action::IcarusAction, pub ica_action: models::icarus_action::IcarusAction,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
enum ActionValues { enum ActionValues {
DeleteAct, DeleteAct,
@@ -283,7 +282,7 @@ impl CommitManager {
song.filepath = Some(s.clone()); song.filepath = Some(s.clone());
song.directory = Some(sourcepath.clone()); song.directory = Some(sourcepath.clone());
self.initialize_disc_and_track(&mut song); self.initialize_disc_and_track(&mut song);
}, }
Err(er) => println!("Error: {:?}", er), Err(er) => println!("Error: {:?}", er),
} }
@@ -314,9 +313,13 @@ impl CommitManager {
Ok(()) Ok(())
} }
// Makes sure the elements in album.songs is populated // Makes sure the elements in album.songs is populated
fn song_parsing(&self, album: &mut models::song::Album, directory: &String, filenames: &Vec<String>) { fn song_parsing(
&self,
album: &mut models::song::Album,
directory: &String,
filenames: &Vec<String>,
) {
// Apply directory // Apply directory
for song in &mut album.songs { for song in &mut album.songs {
// let bor = song.as_mut(); // let bor = song.as_mut();
@@ -325,7 +328,7 @@ impl CommitManager {
Some(s) => println!("{}", s), Some(s) => println!("{}", s),
None => { None => {
song.directory = Some(directory.clone()); song.directory = Some(directory.clone());
}, }
} }
} }
@@ -339,24 +342,24 @@ impl CommitManager {
for song in &mut album.songs { for song in &mut album.songs {
match &mut song.album { match &mut song.album {
Some(_) => {}, Some(_) => {}
None => { None => {
song.album = Some(album.title.clone()); song.album = Some(album.title.clone());
}, }
} }
match &mut song.genre { match &mut song.genre {
Some(_) => {}, Some(_) => {}
None => { None => {
song.genre = Some(album.genre.clone()); song.genre = Some(album.genre.clone());
}, }
} }
match &mut song.year { match &mut song.year {
Some(_) => {}, Some(_) => {}
None => { None => {
song.year = Some(album.year.clone()); song.year = Some(album.year.clone());
}, }
} }
} }
} }
+2 -2
View File
@@ -147,10 +147,10 @@ impl CoverArt {
match &self.path { match &self.path {
Some(val) => { Some(val) => {
path = String::from(val); path = String::from(val);
}, }
None => { None => {
(); ();
}, }
} }
let mut file = std::fs::File::open(path)?; let mut file = std::fs::File::open(path)?;
+11 -10
View File
@@ -1,12 +1,12 @@
use std::default::Default; use std::default::Default;
use reqwest;
use reqwest::blocking::multipart; use reqwest::blocking::multipart;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use reqwest;
// use reqwest::blocking:: // use reqwest::blocking::
use reqwest::{Body, Client};
use reqwest::multipart::{Form, Part}; use reqwest::multipart::{Form, Part};
use reqwest::Response; use reqwest::Response;
use reqwest::{Body, Client};
use tokio::fs::File; use tokio::fs::File;
use crate::models; use crate::models;
@@ -15,7 +15,6 @@ pub struct Upload {
pub api: models::api::API, pub api: models::api::API,
} }
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
struct Song { struct Song {
title: String, title: String,
@@ -62,8 +61,13 @@ impl Upload {
} }
// TODO: Implement // TODO: Implement
pub async fn upload_song_with_metadata(&mut self, token: &models::token::Token, song: &models::song::Song, pub async fn upload_song_with_metadata(
cover: &models::song::CoverArt, album: &models::song::Album) { &mut self,
token: &models::token::Token,
song: &models::song::Song,
cover: &models::song::CoverArt,
album: &models::song::Album,
) {
self.api.endpoint = String::from("song/data/upload/with/data"); self.api.endpoint = String::from("song/data/upload/with/data");
let url = self.retrieve_url(&song); let url = self.retrieve_url(&song);
let client = reqwest::Client::new(); let client = reqwest::Client::new();
@@ -74,8 +78,7 @@ impl Upload {
let cover_data = cover.to_data(); let cover_data = cover.to_data();
match song_data { match song_data {
Ok(sd) => { Ok(sd) => {}
},
Err(er) => { Err(er) => {
println!("Error: {:?}", er); println!("Error: {:?}", er);
std::process::exit(-1); std::process::exit(-1);
@@ -83,7 +86,7 @@ impl Upload {
} }
match cover_data { match cover_data {
Ok(_) => {}, Ok(_) => {}
Err(er) => { Err(er) => {
println!("Error: {:?}", er); println!("Error: {:?}", er);
std::process::exit(-1); std::process::exit(-1);
@@ -119,8 +122,6 @@ impl Upload {
*/ */
} }
pub fn set_api(&mut self, host: &String) { pub fn set_api(&mut self, host: &String) {
let mut api = models::api::API::default(); let mut api = models::api::API::default();
api.url = host.clone(); api.url = host.clone();