Compare commits

..

2 Commits

Author SHA1 Message Date
678d2c2b3d tsk-85: Add file_type to CoverArt (#89)
All checks were successful
Release Tagging / release (push) Successful in 32s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 1m1s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 32s
Closes #85

Reviewed-on: #89
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-29 18:14:23 +00:00
b5429f80b0 tsk-86: Make MusicTypes and CoverArtTypes singular (#88)
All checks were successful
Release Tagging / release (push) Successful in 34s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 34s
Rust Build / build (push) Successful in 32s
Closes #86

Reviewed-on: #88
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-29 18:00:56 +00:00
5 changed files with 15 additions and 17 deletions

2
Cargo.lock generated
View File

@@ -149,7 +149,7 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
[[package]]
name = "icarus_models"
version = "0.9.0"
version = "0.9.1"
dependencies = [
"josekit",
"rand",

View File

@@ -1,6 +1,6 @@
[package]
name = "icarus_models"
version = "0.9.0"
version = "0.9.1"
edition = "2024"
rust-version = "1.90"
description = "models used for the icarus project"

View File

@@ -11,6 +11,7 @@ pub struct CoverArt {
#[serde(skip)]
pub directory: String,
pub filename: String,
pub file_type: String,
#[serde(skip)]
pub data: Vec<u8>,
pub song_id: uuid::Uuid,
@@ -86,20 +87,20 @@ impl CoverArt {
/// Generates filename for a CoverArt
pub fn generate_filename(
typ: crate::types::CoverArtTypes,
typ: crate::types::CoverArtType,
randomize: bool,
) -> Result<String, std::io::Error> {
let file_extension = match typ {
crate::types::CoverArtTypes::PngExtension => {
crate::types::CoverArtType::PngExtension => {
String::from(crate::constants::file_extensions::image::PNGEXTENSION)
}
crate::types::CoverArtTypes::JpegExtension => {
crate::types::CoverArtType::JpegExtension => {
String::from(crate::constants::file_extensions::image::JPEGEXTENSION)
}
crate::types::CoverArtTypes::JpgExtension => {
crate::types::CoverArtType::JpgExtension => {
String::from(crate::constants::file_extensions::image::JPGEXTENSION)
}
crate::types::CoverArtTypes::None => {
crate::types::CoverArtType::None => {
return Err(std::io::Error::other("Unsupported CoverArtTypes"));
}
};

View File

@@ -126,24 +126,21 @@ impl Song {
}
/// Generates a filename. In order to save a song to the filesystem
pub fn generate_filename(
typ: types::MusicTypes,
randomize: bool,
) -> Result<String, std::io::Error> {
pub fn generate_filename(typ: types::MusicType, randomize: bool) -> Result<String, std::io::Error> {
let file_extension = match typ {
types::MusicTypes::DefaultMusicExtension => {
types::MusicType::DefaultMusicExtension => {
String::from(constants::file_extensions::audio::DEFAULTMUSICEXTENSION)
}
types::MusicTypes::WavExtension => {
types::MusicType::WavExtension => {
String::from(constants::file_extensions::audio::WAVEXTENSION)
}
types::MusicTypes::FlacExtension => {
types::MusicType::FlacExtension => {
String::from(constants::file_extensions::audio::FLACEXTENSION)
}
types::MusicTypes::MPThreeExtension => {
types::MusicType::MPThreeExtension => {
String::from(constants::file_extensions::audio::MPTHREEEXTENSION)
}
types::MusicTypes::None => return Err(std::io::Error::other("Unsupported MusicTypes")),
types::MusicType::None => return Err(std::io::Error::other("Unsupported MusicTypes")),
};
let filename: String = if randomize {

View File

@@ -107,7 +107,7 @@ mod song_tests {
};
assert_eq!(song.directory.is_empty(), false);
match song::generate_filename(types::MusicTypes::FlacExtension, true) {
match song::generate_filename(types::MusicType::FlacExtension, true) {
Ok(filename) => {
song_cpy.filename = filename;
}