This crate provides two MediaType structs:
MediaType
and
MediaTypeBuf
.
MediaType
does not copy data during parsing
and just holds reference to the original string. It is also const-constructible.MediaTypeBuf
is an owned and immutable version of MediaType
.```rust use mediatype::{names::*, MediaType, MediaTypeBuf};
const TEXTPLAIN: MediaType = MediaType::new(TEXT, PLAIN); let textplain: MediaTypeBuf = "text/plain".parse().unwrap();
asserteq!(textplain, TEXT_PLAIN);
match (textplain.ty(), textplain.subty()) { ("text", "plain") => println!("plain text!"), ("text", _) => println!("structured text"), _ => println!("not text"), } ```