37 releases

0.3.13 Jan 11, 2019
0.3.12 Oct 15, 2018
0.3.9 Aug 10, 2018
0.3.8 Jul 2, 2018
0.0.1 Nov 20, 2014

#1 in Email

Download history 44849/week @ 2019-01-20 43875/week @ 2019-01-27 41891/week @ 2019-02-03 46283/week @ 2019-02-10 46246/week @ 2019-02-17 52816/week @ 2019-02-24 54373/week @ 2019-03-03 54751/week @ 2019-03-10 55095/week @ 2019-03-17 48932/week @ 2019-03-24 56245/week @ 2019-03-31 60298/week @ 2019-04-07 53839/week @ 2019-04-14 48849/week @ 2019-04-21 51175/week @ 2019-04-28

162,404 downloads per month
Used in 2,373 crates (535 directly)

MIT/Apache

38KB
953 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"),
}

Dependencies

~89KB