33 releases

0.3.9 Aug 10, 2018
0.3.8 Jul 2, 2018
0.3.7 May 4, 2018
0.3.5 Oct 11, 2017
0.0.1 Nov 20, 2014

#4 in Encoding

Download history 25799/week @ 2018-05-19 27026/week @ 2018-05-26 25237/week @ 2018-06-02 29528/week @ 2018-06-09 24982/week @ 2018-06-16 27959/week @ 2018-06-23 24675/week @ 2018-06-30 26149/week @ 2018-07-07 28818/week @ 2018-07-14 30099/week @ 2018-07-21 27252/week @ 2018-07-28 28426/week @ 2018-08-04 27238/week @ 2018-08-11

117,725 downloads per month
Used in 1,738 crates (422 directly)

MIT/Apache

37KB
919 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

~80KB