35 releases

0.3.14 Sep 9, 2019
0.3.13 Jan 11, 2019
0.3.12 Oct 15, 2018
0.3.8 Jul 2, 2018
0.0.1 Nov 20, 2014

#2 in Email

Download history 72725/week @ 2019-07-28 72315/week @ 2019-08-04 73829/week @ 2019-08-11 68328/week @ 2019-08-18 68257/week @ 2019-08-25 69540/week @ 2019-09-01 79156/week @ 2019-09-08 84917/week @ 2019-09-15 86308/week @ 2019-09-22 96133/week @ 2019-09-29 94208/week @ 2019-10-06 92384/week @ 2019-10-13 98107/week @ 2019-10-20 93561/week @ 2019-10-27 99504/week @ 2019-11-03

286,221 downloads per month
Used in 2,977 crates (630 directly)

MIT/Apache

39KB
958 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