Added tests (#12)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 27s
Rust Build / Test Suite (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 28s
Rust Build / build (push) Successful in 25s
Rust Build / Check (pull_request) Successful in 26s
Rust Build / Test Suite (pull_request) Successful in 26s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 25s

Reviewed-on: phoenix/icarus-models#12
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
This commit is contained in:
2025-03-22 20:32:04 +00:00
committed by phoenix
parent ae2fd07229
commit bc3aace070
9 changed files with 180 additions and 33 deletions

View File

@@ -1,4 +1,3 @@
// use std::default::Default;
use std::io::Read;
use crate::constants;
@@ -7,7 +6,7 @@ use crate::types;
use rand::Rng;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Song {
#[serde(skip_serializing_if = "is_zero")]
#[serde(alias = "id")]
@@ -64,37 +63,6 @@ fn is_dur_not_set(num: &i32) -> bool {
*num == 0
}
/*
impl Default for Song {
fn default() -> Self {
Song {
id: 0,
title: String::new(),
artist: String::new(),
album: String::new(),
album_artist: String::new(),
genre: String::new(),
year: 0,
duration: 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,
}
}
}
*/
impl Song {
pub fn to_metadata_json(&self, pretty: bool) -> Result<String, serde_json::Error> {
if pretty {