use u16 for mime lookup

master
Ondřej Hruška 4 years ago
parent 1eb497fccb
commit 5e24b70460
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 8
      src/well_known_mime.rs

@ -6,7 +6,7 @@ use lazy_static::lazy_static;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash)]
pub enum Mime {
/// Well-known mime
WellKnown(usize),
WellKnown(u16),
/// Custom mime
Custom(String),
}
@ -35,7 +35,7 @@ impl Display for Mime {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Mime::WellKnown(n) => {
if let Some(s) = WELL_KNOWN.get(*n) {
if let Some(s) = WELL_KNOWN.get(*n as usize) {
f.write_str(s)
} else {
f.write_str("application/octet-stream")
@ -749,10 +749,10 @@ const WELL_KNOWN : &[&str] = &[
use std::collections::HashMap;
lazy_static!{
static ref MIME_LOOKUP : HashMap<&'static str, usize> = {
static ref MIME_LOOKUP : HashMap<&'static str, u16> = {
let mut map = HashMap::new();
for (n, entry) in WELL_KNOWN.iter().enumerate() {
map.insert(*entry, n);
map.insert(*entry, n as u16);
}
map
};

Loading…
Cancel
Save