From b176088cd324491cff681ff71a69fbc880a88c6d Mon Sep 17 00:00:00 2001 From: Hubert Figuière Date: Mon, 22 Jan 2024 23:30:53 -0500 Subject: api: Added mime_types() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hubert Figuière --- src/identify.rs | 16 ++++++++++++++++ src/lib.rs | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/identify.rs b/src/identify.rs index 76cc484..1c64db2 100644 --- a/src/identify.rs +++ b/src/identify.rs @@ -24,6 +24,8 @@ use std::collections::HashMap; use std::io::{Read, Seek, SeekFrom}; +use once_cell::sync::Lazy; + use super::{Error, Result, Type}; use crate::fujifilm; use crate::io::View; @@ -80,6 +82,20 @@ lazy_static::lazy_static! { ); } +static MIME_TYPES: Lazy> = Lazy::new(|| { + crate::identify::TYPE_MIME + .iter() + .filter_map(|(_, m)| { + Some(String::from(*m)) + }) + .collect() +}); + +/// Return the list of supported mimetypes +pub fn mime_types() -> &'static [String] { + &MIME_TYPES +} + /// Get the mime type associated for the file. pub(crate) fn mime_for_type(type_: Type) -> Option<&'static str> { TYPE_TO_MIME.get(&type_).copied() diff --git a/src/lib.rs b/src/lib.rs index a33eab5..ae31ba2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -335,6 +335,8 @@ static EXTENSIONS: Lazy> = Lazy::new(|| { .collect() }); +pub use crate::identify::mime_types; + /// Return the extensions for raw files (in lowercase). pub fn extensions() -> &'static [String] { &EXTENSIONS -- cgit v1.2.3