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

#7 in Web programming

Download history 1216060/week @ 2024-01-13 1272287/week @ 2024-01-20 1334405/week @ 2024-01-27 1351093/week @ 2024-02-03 1350727/week @ 2024-02-10 1323842/week @ 2024-02-17 1421374/week @ 2024-02-24 1433064/week @ 2024-03-02 1399890/week @ 2024-03-09 1421918/week @ 2024-03-16 1403886/week @ 2024-03-23 1429363/week @ 2024-03-30 1400358/week @ 2024-04-06 1421701/week @ 2024-04-13 1454979/week @ 2024-04-20 1147568/week @ 2024-04-27

5,666,289 downloads per month
Used in 17,480 crates (1,430 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