Expand description
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 ofMediaType
.
use mediatype::{names::*, MediaType, MediaTypeBuf};
const TEXT_PLAIN: MediaType = MediaType::new(TEXT, PLAIN);
let text_plain: MediaTypeBuf = "text/plain".parse().unwrap();
assert_eq!(text_plain, TEXT_PLAIN);
match (text_plain.ty(), text_plain.subty()) {
("text", "plain") => println!("plain text!"),
("text", _) => println!("structured text"),
_ => println!("not text"),
}
Modules
Structs
A parsed MediaType.
An owned and immutable MediaType.
A MediaType name.
An iterator over the parameters.
A MediaType parameter value.
Enums
Parsing error.