Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hyperium/mime

MIMEs in Rust
https://github.com/hyperium/mime

Last synced: 2 days ago
JSON representation

MIMEs in Rust

Awesome Lists containing this project

README

        

# mime

[![Build Status](https://travis-ci.org/hyperium/mime.svg?branch=master)](https://travis-ci.org/hyperium/mime)
[![crates.io](https://img.shields.io/crates/v/mime.svg)](https://crates.io/crates/mime)
[![docs.rs](https://docs.rs/mime/badge.svg)](https://docs.rs/mime)

Support MIME (HTTP Media Types) as strong types in Rust.

[Documentation](https://docs.rs/mime)

## Usage

```rust
extern crate mime;

fn main() {
// 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!
}
}
}
```