38 releases

Uses old Rust 2015

0.3.17 Mar 20, 2023
0.3.16 Jan 7, 2020
0.3.14 Sep 9, 2019
0.3.13 Jan 11, 2019
0.0.1 Nov 20, 2014

#8 in Web programming

Download history 1574682/week @ 2024-07-17 1578851/week @ 2024-07-24 1614496/week @ 2024-07-31 1684933/week @ 2024-08-07 1588978/week @ 2024-08-14 1672261/week @ 2024-08-21 1562233/week @ 2024-08-28 1732099/week @ 2024-09-04 1615377/week @ 2024-09-11 1731999/week @ 2024-09-18 1875220/week @ 2024-09-25 2226869/week @ 2024-10-02 2259524/week @ 2024-10-09 2376552/week @ 2024-10-16 1870637/week @ 2024-10-23 1747896/week @ 2024-10-30

8,698,577 downloads per month
Used in 20,405 crates (1,529 directly)

MIT/Apache

43KB
1K SLoC

mime

Build Status crates.io docs.rs

Support MIME (Media Types) as strong types in Rust.

Documentation

Usage

extern crate mime;

// common types are constants
let text = mime::TEXT_PLAIN;

// deconstruct Mimes to match on them
match (text.type_(), text.subtype()) {
    (mime::TEXT, mime::PLAIN) => {
        // plain text!
    },
    (mime::TEXT, _) => {
        // structured text!
    },
    _ => {
        // not text!
    }
}

lib.rs:

Mime

Mime is now Media Type, technically, but Mime is more immediately understandable, so the main type here is Mime.

What is Mime?

Example mime string: text/plain

let plain_text: mime::Mime = "text/plain".parse().unwrap();
assert_eq!(plain_text, mime::TEXT_PLAIN);

Inspecting Mimes

let mime = mime::TEXT_PLAIN;
match (mime.type_(), mime.subtype()) {
    (mime::TEXT, mime::PLAIN) => println!("plain text!"),
    (mime::TEXT, _) => println!("structured text"),
    _ => println!("not text"),
}

No runtime deps