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

#128 in Multimedia

Download history 1170516/week @ 2024-01-11 1318858/week @ 2024-01-18 1275560/week @ 2024-01-25 1359516/week @ 2024-02-01 1358826/week @ 2024-02-08 1305405/week @ 2024-02-15 1384798/week @ 2024-02-22 1472060/week @ 2024-02-29 1390319/week @ 2024-03-07 1418714/week @ 2024-03-14 1418636/week @ 2024-03-21 1392182/week @ 2024-03-28 1422148/week @ 2024-04-04 1426722/week @ 2024-04-11 1426955/week @ 2024-04-18 1186517/week @ 2024-04-25

5,736,406 downloads per month
Used in 17,468 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