Removing some code (#44)
All checks were successful
Release Tagging / release (push) Successful in 30s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Check (push) Successful in 28s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 28s
Rust Build / build (push) Successful in 27s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 28s
Rust Build / build (pull_request) Successful in 26s
All checks were successful
Release Tagging / release (push) Successful in 30s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Check (push) Successful in 28s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 28s
Rust Build / build (push) Successful in 27s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 28s
Rust Build / build (pull_request) Successful in 26s
Taking out code that wasn't being used and was commented. Reviewed-on: #44 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
149
src/song.rs
149
src/song.rs
@@ -46,6 +46,7 @@ pub struct Song {
|
||||
pub data: Vec<u8>,
|
||||
#[serde(skip)]
|
||||
pub directory: String,
|
||||
// TODO: Think about what to do with this
|
||||
// #[serde(skip)]
|
||||
// pub album_id: i32,
|
||||
// #[serde(skip)]
|
||||
@@ -150,151 +151,3 @@ impl Song {
|
||||
filename
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
mod embedded {
|
||||
use std::io::Read;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
impl Song {
|
||||
pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> {
|
||||
if pretty {
|
||||
serde_json::to_string_pretty(&self)
|
||||
} else {
|
||||
serde_json::to_string(&self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn song_path(&self) -> Result<String, std::io::Error> {
|
||||
if self.directory.is_empty() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"Directory does not exist",
|
||||
));
|
||||
}
|
||||
|
||||
let directory = &self.directory;
|
||||
let mut buffer: String = directory.clone();
|
||||
let last_index = directory.len() - 1;
|
||||
|
||||
if let Some(character) = directory.chars().nth(last_index) {
|
||||
if character != '/' {
|
||||
buffer += "/";
|
||||
}
|
||||
|
||||
buffer += &self.filename.clone();
|
||||
|
||||
Ok(buffer)
|
||||
} else {
|
||||
Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"Could not access last character of directory",
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
|
||||
let path_result = self.song_path();
|
||||
|
||||
match path_result {
|
||||
Ok(path) => {
|
||||
let mut file = std::fs::File::open(path)?;
|
||||
let mut buffer: Vec<u8> = Vec::new();
|
||||
file.read_to_end(&mut buffer)?;
|
||||
|
||||
if buffer.is_empty() {
|
||||
Err(std::io::Error::new(
|
||||
std::io::ErrorKind::Other,
|
||||
"File is empty",
|
||||
))
|
||||
} else {
|
||||
Ok(buffer)
|
||||
}
|
||||
}
|
||||
Err(er) => Err(er),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The song's duration is a floating point in seconds
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Song {
|
||||
#[serde(skip_serializing_if = "init::is_uuid_nil")]
|
||||
#[serde(alias = "id")]
|
||||
pub id: uuid::Uuid,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub title: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub artist: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub album: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub album_artist: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub genre: String,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub year: i32,
|
||||
#[serde(skip_serializing_if = "init::is_embed_dur_not_set")]
|
||||
pub duration: f64,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub track: i32,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub disc: i32,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub disc_count: i32,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub track_count: i32,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub audio_type: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub date_created: String,
|
||||
#[serde(skip_serializing_if = "String::is_empty")]
|
||||
pub filename: String,
|
||||
#[serde(skip_serializing_if = "init::is_embed_zero")]
|
||||
pub user_id: i32,
|
||||
#[serde(skip)]
|
||||
pub data: Vec<u8>,
|
||||
#[serde(skip)]
|
||||
pub directory: String,
|
||||
// #[serde(skip)]
|
||||
// pub album_id: i32,
|
||||
// #[serde(skip)]
|
||||
// pub artist_id: i32,
|
||||
// #[serde(skip)]
|
||||
// pub genre_id: i32,
|
||||
// #[serde(skip)]
|
||||
// pub coverart_id: i32,
|
||||
}
|
||||
|
||||
|
||||
impl Default for Song {
|
||||
fn default() -> Self {
|
||||
Song {
|
||||
id: uuid::Uuid::nil(),
|
||||
title: String::new(),
|
||||
artist: String::new(),
|
||||
album: String::new(),
|
||||
album_artist: String::new(),
|
||||
genre: String::new(),
|
||||
year: 0,
|
||||
duration: 0.0,
|
||||
track: 0,
|
||||
disc: 0,
|
||||
disc_count: 0,
|
||||
track_count: 0,
|
||||
audio_type: String::new(),
|
||||
date_created: String::new(),
|
||||
filename: String::new(),
|
||||
user_id: 0,
|
||||
data: Vec::new(),
|
||||
directory: String::new(),
|
||||
// album_id: 0,
|
||||
// artist_id: 0,
|
||||
// genre_id: 0,
|
||||
// coverart_id: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user