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 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 52082/week @ 2019-05-05 57432/week @ 2019-05-12 57440/week @ 2019-05-19 55190/week @ 2019-05-26 64545/week @ 2019-06-02 62040/week @ 2019-06-09 64390/week @ 2019-06-16 63039/week @ 2019-06-23 55637/week @ 2019-06-30

232,721 downloads per month
Used in 2,572 crates (604 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

~85KB