rom_thumbnails/lib.rs
1//! This crate contains decoding functions for the embedded icons of
2//! several video game console ROM formats.
3//!
4//! The main use-case is to write thumbnailers for file managers.
5use camino::Utf8PathBuf;
6
7pub mod error;
8pub mod image;
9pub mod nds;
10
11/// Extracts the thumbnail for a given `path` as an `image::RgbaImage`.
12///
13/// # Errors
14/// All errors are contained in variants of the [`ThumbnailerError`] enum.
15///
16/// [`ThumbnailerError`]: error/enum.ThumbnailerError.html
17///
18pub fn extract_thumbnail(path: &str) -> Result<image::Image, error::ThumbnailerError> {
19 let path = Utf8PathBuf::from(path);
20 match path.extension() {
21 None => Err(error::ThumbnailerError::NoExtension),
22 Some(ext) => match ext {
23 "nds" => nds::extract_thumbnail(&path),
24 _ => Err(error::ThumbnailerError::UnsupportedExtension),
25 },
26 }
27}