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 55683/week @ 2019-05-27 65029/week @ 2019-06-03 61374/week @ 2019-06-10 64989/week @ 2019-06-17 62342/week @ 2019-06-24 56261/week @ 2019-07-01 63304/week @ 2019-07-08 67587/week @ 2019-07-15 69373/week @ 2019-07-22 72287/week @ 2019-07-29 72557/week @ 2019-08-05 73579/week @ 2019-08-12 68612/week @ 2019-08-19 68301/week @ 2019-08-26 69581/week @ 2019-09-02

286,221 downloads per month
Used in 2,793 crates (620 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