mirror of
https://gitee.com/openharmony/third_party_rust_mime
synced 2024-11-23 05:00:04 +00:00
9306339249
Merge pull request !2 from peizhe/master |
||
---|---|---|
benches | ||
src | ||
.gitignore | ||
.travis.yml | ||
BUILD.gn | ||
Cargo.toml | ||
CONTRIBUTING.md | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
README.OpenSource |
mime
Support MIME (Media Types) as strong types in Rust.
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!
}
}