//! This crate contains decoding functions for the embedded icons of
//! several video game console ROM formats.
//!
//! The main use-case is to write thumbnailers for file managers.
use camino::Utf8PathBuf;
pub mod error;
pub mod image;
pub mod nds;
/// Extracts the thumbnail for a given `path` as an `image::RgbaImage`.
///
/// # Errors
/// All errors are contained in variants of the [`ThumbnailerError`] enum.
///
/// [`ThumbnailerError`]: error/enum.ThumbnailerError.html
///
pub fn extract_thumbnail(path: &str) -> Result<image::Image, error::ThumbnailerError> {
let path = Utf8PathBuf::from(path);
match path.extension() {
None => Err(error::ThumbnailerError::NoExtension),
Some(ext) => match ext {
"nds" => nds::extract_thumbnail(&path),
_ => Err(error::ThumbnailerError::UnsupportedExtension),
},
}
}