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

#10 in Web programming

Download history 1830846/week @ 2024-11-16 1573049/week @ 2024-11-23 1822614/week @ 2024-11-30 2167240/week @ 2024-12-07 1841950/week @ 2024-12-14 915986/week @ 2024-12-21 1097818/week @ 2024-12-28 1899328/week @ 2025-01-04 2112524/week @ 2025-01-11 1941095/week @ 2025-01-18 2057401/week @ 2025-01-25 2324526/week @ 2025-02-01 2402939/week @ 2025-02-08 2388143/week @ 2025-02-15 2513649/week @ 2025-02-22 2326737/week @ 2025-03-01

10,027,096 downloads per month
Used in 22,761 crates (1,568 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