37 releases

0.3.16 Jan 7, 2020
0.3.14 Sep 9, 2019
0.3.13 Jan 11, 2019
0.3.12 Oct 15, 2018
0.0.1 Nov 20, 2014

#2 in Email

Download history 94525/week @ 2019-11-01 95819/week @ 2019-11-08 101050/week @ 2019-11-15 101807/week @ 2019-11-22 103848/week @ 2019-11-29 115720/week @ 2019-12-06 110878/week @ 2019-12-13 71067/week @ 2019-12-20 67558/week @ 2019-12-27 119454/week @ 2020-01-03 133419/week @ 2020-01-10 130991/week @ 2020-01-17 132090/week @ 2020-01-24 130286/week @ 2020-01-31 116436/week @ 2020-02-07

410,091 downloads per month
Used in 3,350 crates (670 directly)

MIT/Apache

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