38 releases

Uses old Rust 2015

0.3.17 Mar 20, 2023
0.3.16 Jan 7, 2020
0.3.14 Sep 9, 2019
0.3.13 Jan 11, 2019
0.0.1 Nov 20, 2014

#9 in Web programming

Download history 1635328/week @ 2024-09-10 1699490/week @ 2024-09-17 1817967/week @ 2024-09-24 2177677/week @ 2024-10-01 2356162/week @ 2024-10-08 2340596/week @ 2024-10-15 1905134/week @ 2024-10-22 1758678/week @ 2024-10-29 1736750/week @ 2024-11-05 1839675/week @ 2024-11-12 1826622/week @ 2024-11-19 1564469/week @ 2024-11-26 1889429/week @ 2024-12-03 2142383/week @ 2024-12-10 1693883/week @ 2024-12-17 889846/week @ 2024-12-24

6,940,321 downloads per month
Used in 21,333 crates (1,545 directly)

MIT/Apache

43KB
1K SLoC

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