#mime #media-extensions #media-types #no-std

no-std mime-db

Media Type Database, looks up extension or media type

10 releases (4 stable)

1.3.0 Apr 6, 2021
1.2.0 Feb 19, 2021
1.1.0 Oct 6, 2020
1.0.0 Aug 9, 2020
0.1.3 Dec 12, 2019

#73 in Database interfaces

Download history 71/week @ 2020-12-24 101/week @ 2020-12-31 38/week @ 2021-01-07 64/week @ 2021-01-14 52/week @ 2021-01-21 87/week @ 2021-01-28 123/week @ 2021-02-04 179/week @ 2021-02-11 75/week @ 2021-02-18 134/week @ 2021-02-25 155/week @ 2021-03-04 98/week @ 2021-03-11 120/week @ 2021-03-18 171/week @ 2021-03-25 92/week @ 2021-04-01 132/week @ 2021-04-08

455 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

69KB
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–0.8MB
~19K SLoC