33 releases

0.3.9 Aug 10, 2018
0.3.8 Jul 2, 2018
0.3.7 May 4, 2018
0.3.5 Oct 11, 2017
0.0.1 Nov 20, 2014

#4 in Encoding

Download history 26669/week @ 2018-08-04 28448/week @ 2018-08-11 28209/week @ 2018-08-18 27969/week @ 2018-08-25 31166/week @ 2018-09-01 29924/week @ 2018-09-08 30546/week @ 2018-09-15 30974/week @ 2018-09-22 30353/week @ 2018-09-29 34097/week @ 2018-10-06 32766/week @ 2018-10-13 37216/week @ 2018-10-20 34690/week @ 2018-10-27

117,725 downloads per month
Used in 1,885 crates (495 directly)

MIT/Apache

37KB
919 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