37 releases

0.3.16 Jan 7, 2020
0.3.14 Sep 9, 2019
0.3.13 Jan 11, 2019
0.3.12 Oct 15, 2018
0.0.1 Nov 20, 2014

#2 in Email

Download history 101712/week @ 2019-12-17 61989/week @ 2019-12-24 76921/week @ 2019-12-31 134936/week @ 2020-01-07 132516/week @ 2020-01-14 130369/week @ 2020-01-21 135158/week @ 2020-01-28 129219/week @ 2020-02-04 122507/week @ 2020-02-11 121222/week @ 2020-02-18 130426/week @ 2020-02-25 131513/week @ 2020-03-03 131378/week @ 2020-03-10 136021/week @ 2020-03-17 134139/week @ 2020-03-24 127621/week @ 2020-03-31

410,091 downloads per month
Used in 3,529 crates (681 directly)

MIT/Apache

39KB
980 lines

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