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
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
This commit is contained in:
20
src/detection/coverart.rs
Normal file
20
src/detection/coverart.rs
Normal 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
1
src/detection/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod coverart;
|
@@ -1,3 +1,4 @@
|
||||
pub mod detection;
|
||||
pub mod meta;
|
||||
pub mod properties;
|
||||
pub mod types;
|
||||
|
Reference in New Issue
Block a user