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,
}
#[derive(Clone, Debug)]
enum ActionValues {
DeleteAct,
@@ -283,7 +282,7 @@ impl CommitManager {
song.filepath = Some(s.clone());
song.directory = Some(sourcepath.clone());
self.initialize_disc_and_track(&mut song);
},
}
Err(er) => println!("Error: {:?}", er),
}
@@ -314,9 +313,13 @@ impl CommitManager {
Ok(())
}
// 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
for song in &mut album.songs {
// let bor = song.as_mut();
@@ -325,7 +328,7 @@ impl CommitManager {
Some(s) => println!("{}", s),
None => {
song.directory = Some(directory.clone());
},
}
}
}
@@ -339,24 +342,24 @@ impl CommitManager {
for song in &mut album.songs {
match &mut song.album {
Some(_) => {},
Some(_) => {}
None => {
song.album = Some(album.title.clone());
},
}
}
match &mut song.genre {
Some(_) => {},
Some(_) => {}
None => {
song.genre = Some(album.genre.clone());
},
}
}
match &mut song.year {
Some(_) => {},
Some(_) => {}
None => {
song.year = Some(album.year.clone());
},
}
}
}
}
+4 -4
View File
@@ -93,7 +93,7 @@ impl Song {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path = self.song_path();
// let content = std::fs::read_to_string(path);
let mut file = std::fs::File::open(path)?;
let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new();
file.read(&mut buffer)?;
Ok(buffer)
@@ -147,10 +147,10 @@ impl CoverArt {
match &self.path {
Some(val) => {
path = String::from(val);
},
}
None => {
();
},
}
}
let mut file = std::fs::File::open(path)?;
@@ -158,4 +158,4 @@ impl CoverArt {
file.read(&mut buffer)?;
Ok(buffer)
}
}
}
+18 -17
View File
@@ -1,12 +1,12 @@
use std::default::Default;
use reqwest;
use reqwest::blocking::multipart;
use serde::{Deserialize, Serialize};
use reqwest;
// use reqwest::blocking::
use reqwest::{Body, Client};
use reqwest::multipart::{Form, Part};
use reqwest::Response;
use reqwest::{Body, Client};
use tokio::fs::File;
use crate::models;
@@ -15,7 +15,6 @@ pub struct Upload {
pub api: models::api::API,
}
#[derive(Debug, Deserialize, Serialize)]
struct Song {
title: String,
@@ -62,20 +61,24 @@ impl Upload {
}
// TODO: Implement
pub async fn upload_song_with_metadata(&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");
let url = self.retrieve_url(&song);
let client = reqwest::Client::new();
let new_song = self.initialize_song(&song, &album);
let access_token = token.bearer_token();
pub async fn upload_song_with_metadata(
&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");
let url = self.retrieve_url(&song);
let client = reqwest::Client::new();
let new_song = self.initialize_song(&song, &album);
let access_token = token.bearer_token();
let song_data = song.to_data();
let cover_data = cover.to_data();
match song_data {
Ok(sd) => {
},
Ok(sd) => {}
Err(er) => {
println!("Error: {:?}", er);
std::process::exit(-1);
@@ -83,7 +86,7 @@ impl Upload {
}
match cover_data {
Ok(_) => {},
Ok(_) => {}
Err(er) => {
println!("Error: {:?}", er);
std::process::exit(-1);
@@ -111,7 +114,7 @@ impl Upload {
form = form.part("file", s_some_file)
.part("cover", c_data);
let response = client.post(url).multipart(form).send();
let result = response.text;
@@ -119,8 +122,6 @@ impl Upload {
*/
}
pub fn set_api(&mut self, host: &String) {
let mut api = models::api::API::default();
api.url = host.clone();