Crates.io | mime-db |
lib.rs | mime-db |
version | 1.8.0 |
source | src |
created_at | 2019-12-10 21:49:55.597923 |
updated_at | 2024-11-23 21:22:07.522374 |
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 | 85,265 |
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");