mime-db

Crates.iomime-db
lib.rsmime-db
version1.8.0
sourcesrc
created_at2019-12-10 21:49:55.597923
updated_at2024-11-23 21:22:07.522374
descriptionMedia Type Database, looks up `extension` or `media type`.
homepage
repositoryhttps://github.com/viz-rs/mime-db
max_upload_size
id188316
size85,265
Fangdun Tsai (fundon)

documentation

README

mime-db

Media Type Database, looks up `extension` or `media type`

Docs.rs docs Crates.io version Download jshttp/mime-db

Installation

cargo add mime-db

Usage

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");

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Commit count: 41

cargo fmt