tsk-44: Code formatting
All checks were successful
Rust Build / Check (pull_request) Successful in 43s
Rust Build / Test Suite (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 38s
Rust Build / build (pull_request) Successful in 1m0s

This commit is contained in:
2025-10-20 20:55:07 -04:00
parent bfb7df2d03
commit b96451bee5

View File

@@ -1,21 +1,11 @@
/// Gets the file type of a CoverArt given it's path /// Gets the file type of a CoverArt given it's path
pub fn file_type(filepath: &str) -> Result<String, std::io::Error> { pub fn file_type(filepath: &str) -> Result<String, std::io::Error> {
match imghdr::from_file(filepath) { match imghdr::from_file(filepath) {
Ok(Some(imghdr::Type::Jpeg)) => { Ok(Some(imghdr::Type::Jpeg)) => Ok(String::from("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")),
Ok(Some(imghdr::Type::Png)) => { Err(err) => Err(err),
Ok(String::from("png")) _ => Err(std::io::Error::other("Image file not supported")),
}
Ok(None) => {
Err(std::io::Error::other("Image file not supported"))
}
Err(err) => {
Err(err)
}
_ => {
Err(std::io::Error::other("Image file not supported"))
}
} }
} }
@@ -29,7 +19,10 @@ mod tests {
match super::file_type(&filepath) { match super::file_type(&filepath) {
Ok(filetype) => { Ok(filetype) => {
assert_eq!(filetype, "png", "The file type of the CoverArt should have been png"); assert_eq!(
filetype, "png",
"The file type of the CoverArt should have been png"
);
} }
Err(err) => { Err(err) => {
assert!(false, "Error: {err:?}"); assert!(false, "Error: {err:?}");