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 1607316/week @ 2024-08-02 1684372/week @ 2024-08-09 1631034/week @ 2024-08-16 1683285/week @ 2024-08-23 1567828/week @ 2024-08-30 1692792/week @ 2024-09-06 1527493/week @ 2024-09-13 1858367/week @ 2024-09-20 1863159/week @ 2024-09-27 2338960/week @ 2024-10-04 2221079/week @ 2024-10-11 2370313/week @ 2024-10-18 1831804/week @ 2024-10-25 1738560/week @ 2024-11-01 1781979/week @ 2024-11-08 1844603/week @ 2024-11-15

7,548,156 downloads per month
Used in 20,672 crates (1,533 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