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

#1 in Multimedia

Download history 40504/week @ 2018-12-01 45009/week @ 2018-12-08 41679/week @ 2018-12-15 27237/week @ 2018-12-22 31507/week @ 2018-12-29 40199/week @ 2019-01-05 45797/week @ 2019-01-12 45063/week @ 2019-01-19 44054/week @ 2019-01-26 41817/week @ 2019-02-02 46652/week @ 2019-02-09 46452/week @ 2019-02-16 51823/week @ 2019-02-23 54675/week @ 2019-03-02 54632/week @ 2019-03-09

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

~83KB