use lazy_static::lazy_static;
use std::collections::HashMap;
lazy_static! {
pub static ref MEDIA_TYPE_STR: HashMap<u16, &'static str> = {
let mut m = HashMap::new();
let mut populate = |subtypes: &[&'static str], range| {
for (i, subtype) in subtypes.iter().enumerate() {
let code = range + (i as u16);
m.insert(code, *subtype);
}
};
populate(&APPLICATION_SUBTYPES, 0x5000);
populate(&AUDIO_SUBTYPES, 0x8000);
populate(&FONT_SUBTYPES, 0x9000);
populate(&IMAGE_SUBTYPES, 0xa000);
populate(&MULTIPART_SUBTYPES, 0xd000);
populate(&TEXT_SUBTYPES, 0xe000);
populate(&VIDEO_SUBTYPES, 0xf000);
m
};
pub static ref MEDIA_TYPE_CODES: HashMap<String, u16> = {
let mut m = HashMap::new();
let mut populate = |subtypes: &[&'static str], range| {
for (i, subtype) in subtypes.iter().enumerate() {
let code = range + (i as u16);
m.insert((*subtype).to_string(), code);
}
};
populate(&APPLICATION_SUBTYPES, 0x5000);
populate(&AUDIO_SUBTYPES, 0x8000);
populate(&FONT_SUBTYPES, 0x9000);
populate(&IMAGE_SUBTYPES, 0xa000);
populate(&MULTIPART_SUBTYPES, 0xd000);
populate(&TEXT_SUBTYPES, 0xe000);
populate(&VIDEO_SUBTYPES, 0xf000);
m
};
}
static APPLICATION_SUBTYPES: [&str; 38] = [
"application/x-abiword",
"application/octet-stream",
"application/vnd.amazon.ebook",
"application/x-bzip",
"application/x-bzip2",
"application/x-csh",
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-fontobject",
"application/epub+zip",
"application/ecmascript",
"application/java-archive",
"application/javascript",
"application/json",
"application/vnd.apple.installer+xml",
"application/vnd.oasis.opendocument.presentation",
"application/vnd.oasis.opendocument.spreadsheet",
"application/vnd.oasis.opendocument.text",
"application/ogg",
"application/pdf",
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/x-rar-compressed",
"application/rtf",
"application/x-sh",
"application/x-shockwave-flash",
"application/x-tar",
"application/typescript",
"application/vnd.visio",
"application/xhtml+xml",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/xml",
"application/vnd.mozilla.xul+xml",
"application/zip",
"application/x-7z-compressed",
"application/ld+json",
"application/rdf+xml",
];
static AUDIO_SUBTYPES: [&str; 10] = [
"audio/aac",
"audio/midi",
"audio/x-midi",
"audio/ogg",
"audio/wav",
"audio/webm",
"audio/3gpp",
"audio/3gpp2",
"audio/mp4",
"audio/mpeg",
];
static FONT_SUBTYPES: [&str; 4] = ["font/otf", "font/ttf", "font/woff", "font/woff2"];
static IMAGE_SUBTYPES: [&str; 8] = [
"image/bmp",
"image/gif",
"image/x-icon",
"image/jpeg",
"image/png",
"image/svg+xml",
"image/tiff",
"image/webp",
];
static MULTIPART_SUBTYPES: [&str; 1] = ["multipart/byteranges"];
static TEXT_SUBTYPES: [&str; 10] = [
"text/css",
"text/csv",
"text/html",
"text/calendar",
"text/markdown",
"text/n3",
"text/plain",
"text/turtle",
"text/x-markdown",
"text/xml",
];
static VIDEO_SUBTYPES: [&str; 8] = [
"video/x-msvideo",
"video/mpeg",
"video/ogg",
"video/webm",
"video/3gpp",
"video/3gpp2",
"video/jpeg",
"video/mp4",
];