From b9d9c7feeb0093feba0f17e6c4d64e19e2facd87 Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 6 Nov 2025 10:43:52 -0500 Subject: [PATCH 1/3] tsk-49: Initialize FileType with file type of the media --- src/detection/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/detection/mod.rs b/src/detection/mod.rs index ad6601e..27fbd76 100644 --- a/src/detection/mod.rs +++ b/src/detection/mod.rs @@ -6,3 +6,26 @@ pub struct FileType { pub mime: String, pub file_type: String, } + + +/// Initializes a FileType given a filetype passed. +pub fn init_filetype(filetype: &str) -> Result { + if filetype == song::constants::FLAC_TYPE { + Ok(FileType { + mime: String::from(song::constants::mime::FLAC), + file_type: String::from(song::constants::FLAC_TYPE), + }) + } else if filetype == coverart::constants::PNG_TYPE { + Ok(FileType { + mime: String::from(coverart::constants::mime::PNG), + file_type: String::from(coverart::constants::PNG_TYPE), + }) + } else if filetype == coverart::constants::JPEG_TYPE || filetype == coverart::constants::JPG_TYPE { + Ok(FileType { + mime: String::from(coverart::constants::mime::JPEG), + file_type: String::from(coverart::constants::JPEG_TYPE), + }) + } else { + Err(std::io::Error::other(format!("Unsupported FileType: {filetype:?}"))) + } +} -- 2.43.0 From 9aa2b1d75d9fe550fa35fc117e0c714e9acfe6bd Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 6 Nov 2025 10:46:24 -0500 Subject: [PATCH 2/3] tsk-49: Code formatting --- src/detection/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/detection/mod.rs b/src/detection/mod.rs index 27fbd76..026e209 100644 --- a/src/detection/mod.rs +++ b/src/detection/mod.rs @@ -7,7 +7,6 @@ pub struct FileType { pub file_type: String, } - /// Initializes a FileType given a filetype passed. pub fn init_filetype(filetype: &str) -> Result { if filetype == song::constants::FLAC_TYPE { @@ -20,12 +19,16 @@ pub fn init_filetype(filetype: &str) -> Result { mime: String::from(coverart::constants::mime::PNG), file_type: String::from(coverart::constants::PNG_TYPE), }) - } else if filetype == coverart::constants::JPEG_TYPE || filetype == coverart::constants::JPG_TYPE { + } else if filetype == coverart::constants::JPEG_TYPE + || filetype == coverart::constants::JPG_TYPE + { Ok(FileType { mime: String::from(coverart::constants::mime::JPEG), file_type: String::from(coverart::constants::JPEG_TYPE), }) } else { - Err(std::io::Error::other(format!("Unsupported FileType: {filetype:?}"))) + Err(std::io::Error::other(format!( + "Unsupported FileType: {filetype:?}" + ))) } } -- 2.43.0 From 655988b6895500ec73843cd0a0cae9b93d2b5a7e Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 6 Nov 2025 10:47:00 -0500 Subject: [PATCH 3/3] tsk-49: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3669f4..663a929 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "icarus_meta" -version = "0.4.3" +version = "0.4.4" dependencies = [ "imghdr", "infer", diff --git a/Cargo.toml b/Cargo.toml index 8090b6c..b98b2eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus_meta" -version = "0.4.3" +version = "0.4.4" edition = "2024" rust-version = "1.90" -- 2.43.0