#mime #media-type #no-std #media-extensions

no-std mime-db

Media Type Database, looks up extension or media type

14 releases (8 stable)

1.7.0 Jun 26, 2023
1.6.0 Oct 9, 2021
1.5.0 Sep 11, 2021
1.4.0 Jun 4, 2021
0.1.3 Dec 12, 2019

#358 in Database interfaces

Download history 22/week @ 2024-01-28 1/week @ 2024-02-04 25/week @ 2024-02-11 37/week @ 2024-02-18 129/week @ 2024-02-25 47/week @ 2024-03-03 385/week @ 2024-03-10 136/week @ 2024-03-17 28/week @ 2024-03-24 129/week @ 2024-03-31 52/week @ 2024-04-07 51/week @ 2024-04-14 53/week @ 2024-04-21 33/week @ 2024-04-28 36/week @ 2024-05-05 69/week @ 2024-05-12

193 downloads per month
Used in 3 crates

MIT/Apache

71KB
2.5K SLoC

mime-db

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

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.

No runtime deps

~0–1.8MB
~27K SLoC