Compare commits

...

2 Commits

Author SHA1 Message Date
580d73eeb8 tsk-44: Added detection module
Some checks failed
Rust Build / Clippy (pull_request) Successful in 1m5s
Rust Build / Test Suite (pull_request) Successful in 58s
Rust Build / Check (pull_request) Successful in 47s
Rust Build / build (pull_request) Successful in 1m5s
Rust Build / Rustfmt (pull_request) Failing after 1m19s
2025-10-20 20:19:37 -04:00
9e30c6db00 tsk-44: Added imghdr crate 2025-10-20 20:06:30 -04:00
5 changed files with 30 additions and 0 deletions

7
Cargo.lock generated
View File

@@ -83,10 +83,17 @@ dependencies = [
name = "icarus_meta"
version = "0.4.0"
dependencies = [
"imghdr",
"lofty",
"tempfile",
]
[[package]]
name = "imghdr"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8b35f3ad95576ac81603375dfe47a0450b70a368aa34d2b6e5bb0a0d7f02428"
[[package]]
name = "libc"
version = "0.2.177"

View File

@@ -6,6 +6,7 @@ rust-version = "1.90"
[dependencies]
lofty = { version = "0.22.4" }
imghdr = { version = "0.7.0" }
[dev-dependencies]
tempfile = { version = "3.23.0" }

20
src/detection/coverart.rs Normal file
View File

@@ -0,0 +1,20 @@
/// Gets the file type of a CoverArt given it's path
pub fn file_type(filepath: &str) -> Result<String, std::io::Error> {
match imghdr::from_file(filepath) {
Ok(Some(imghdr::Type::Jpeg)) => {
Ok(String::from("jpeg"))
}
Ok(Some(imghdr::Type::Png)) => {
Ok(String::from("png"))
}
Ok(None) => {
Err(std::io::Error::other("Image file not supported"))
}
Err(err) => {
Err(err)
}
_ => {
Err(std::io::Error::other("Image file not supported"))
}
}
}

1
src/detection/mod.rs Normal file
View File

@@ -0,0 +1 @@
pub mod coverart;

View File

@@ -1,3 +1,4 @@
pub mod detection;
pub mod meta;
pub mod properties;
pub mod types;