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 93452/week @ 2019-10-07 92508/week @ 2019-10-14 98442/week @ 2019-10-21 92657/week @ 2019-10-28 99557/week @ 2019-11-04 95734/week @ 2019-11-11 102023/week @ 2019-11-18 98901/week @ 2019-11-25 110146/week @ 2019-12-02 116194/week @ 2019-12-09 109173/week @ 2019-12-16 62366/week @ 2019-12-23 73053/week @ 2019-12-30 130824/week @ 2020-01-06 128154/week @ 2020-01-13

410,091 downloads per month
Used in 3,241 crates (662 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