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

#3 in Encoding

Download history 30708/week @ 2018-10-21 39097/week @ 2018-10-28 38836/week @ 2018-11-04 38461/week @ 2018-11-11 40560/week @ 2018-11-18 34305/week @ 2018-11-25 39478/week @ 2018-12-02 41804/week @ 2018-12-09 43085/week @ 2018-12-16 42509/week @ 2018-12-23 27039/week @ 2018-12-30 31761/week @ 2019-01-06 39575/week @ 2019-01-13

162,404 downloads per month
Used in 2,049 crates (511 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

~82KB