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

#1 in Multimedia

Download history 1693883/week @ 2024-12-17 889949/week @ 2024-12-24 1206254/week @ 2024-12-31 2022022/week @ 2025-01-07 2033880/week @ 2025-01-14 2009655/week @ 2025-01-21 2106646/week @ 2025-01-28 2377330/week @ 2025-02-04 2272124/week @ 2025-02-11 2569067/week @ 2025-02-18 2482705/week @ 2025-02-25 2876149/week @ 2025-03-04 2872701/week @ 2025-03-11 3354613/week @ 2025-03-18 3070834/week @ 2025-03-25 2259397/week @ 2025-04-01

12,039,815 downloads per month
Used in 23,386 crates (1,570 directly)

MIT/Apache

43KB
1K SLoC

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"),
}

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!
    }
}

No runtime deps