From 56384fb371bb918c17f4a50fc5a076967d5a04e3 Mon Sep 17 00:00:00 2001 From: KD Date: Sat, 29 Mar 2025 22:37:02 +0000 Subject: [PATCH] Added file extension constant and updated constants module (#17) Reviewed-on: https://git.kundeng.us/phoenix/icarus-models/pulls/17 Co-authored-by: KD Co-committed-by: KD --- src/constants.rs | 19 ++++++++++++++----- src/song.rs | 14 ++++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 51dd5ea..4a982b1 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,5 +1,14 @@ -pub const DEFAULTMUSICEXTENSION: &str = FLACEXTENSION; -pub const FLACEXTENSION: &str = ".flac"; -pub const WAVEXTENSION: &str = ".wav"; -pub const MPTHREEEXTENSION: &str = ".mp3"; -pub const JPGEXTENSION: &str = ".jpg"; +pub mod file_extensions { + pub mod audio { + pub const DEFAULTMUSICEXTENSION: &str = FLACEXTENSION; + pub const FLACEXTENSION: &str = ".flac"; + pub const WAVEXTENSION: &str = ".wav"; + pub const MPTHREEEXTENSION: &str = ".mp3"; + } + + pub mod image { + pub const JPGEXTENSION: &str = ".jpg"; + pub const JPEGEXTENSION: &str = ".jpeg"; + pub const PNGEXTENSION: &str = ".png"; + } +} diff --git a/src/song.rs b/src/song.rs index 4d319dc..3f0d15f 100644 --- a/src/song.rs +++ b/src/song.rs @@ -128,12 +128,18 @@ impl Song { let file_extension = match typ { types::MusicTypes::DefaultMusicExtension => { - String::from(constants::DEFAULTMUSICEXTENSION) + String::from(constants::file_extensions::audio::DEFAULTMUSICEXTENSION) } - types::MusicTypes::WavExtension => String::from(constants::WAVEXTENSION), - types::MusicTypes::FlacExtension => String::from(constants::FLACEXTENSION), - types::MusicTypes::MPThreeExtension => String::from(constants::MPTHREEEXTENSION), + types::MusicTypes::WavExtension => { + String::from(constants::file_extensions::audio::WAVEXTENSION) + } + types::MusicTypes::FlacExtension => { + String::from(constants::file_extensions::audio::FLACEXTENSION) + } + types::MusicTypes::MPThreeExtension => { + String::from(constants::file_extensions::audio::MPTHREEEXTENSION) + } }; if randomize {