#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

#321 in Database interfaces

Download history 245/week @ 2024-01-01 90/week @ 2024-01-08 115/week @ 2024-01-15 37/week @ 2024-01-22 22/week @ 2024-01-29 27/week @ 2024-02-12 36/week @ 2024-02-19 133/week @ 2024-02-26 50/week @ 2024-03-04 410/week @ 2024-03-11 112/week @ 2024-03-18 21/week @ 2024-03-25 134/week @ 2024-04-01 49/week @ 2024-04-08 49/week @ 2024-04-15

262 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–2MB
~28K SLoC