Crates.io | mime-db |
lib.rs | mime-db |
version | 1.7.0 |
source | src |
created_at | 2019-12-10 21:49:55.597923 |
updated_at | 2023-06-26 07:04:31.754895 |
description | Media Type Database, looks up `extension` or `media type`. |
homepage | |
repository | https://github.com/viz-rs/mime-db |
max_upload_size | |
id | 188316 |
size | 83,415 |
Media Type Database, looks up `extension` or `media type`
cargo add mime-db
use mime_db::{extension, extensions, lookup};
assert_eq!(lookup("json").unwrap(), "application/json");
assert_eq!(lookup(".md").unwrap(), "text/markdown");
assert_eq!(lookup("folder/file.js").unwrap(), "application/javascript");
assert_eq!(lookup("folder/.htaccess"), None);
assert_eq!(lookup("cats"), None);
assert!(extensions2("application/octet-stream").eq([
"bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc",
"deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"
]
.iter()
.cloned()));
assert_eq!(extension("application/octet-stream").unwrap(), "bin");