Struct http_stub::Mime
[−]
[src]
pub struct Mime<T = Vec<(Attr, Value)>> where T: AsRef<[(Attr, Value)]>(pub TopLevel, pub SubLevel, pub T);
Mime, or Media Type. Encapsulates common registers types.
Consider that a traditional mime type contains a "top level type", a "sub level type", and 0-N "parameters". And they're all strings. Strings everywhere. Strings mean typos. Rust has type safety. We should use types!
So, Mime bundles together this data into types so the compiler can catch your typos.
This improves things so you use match without Strings:
use mime::{Mime, TopLevel, SubLevel}; let mime: Mime = "application/json".parse().unwrap(); match mime { Mime(TopLevel::Application, SubLevel::Json, _) => println!("matched json!"), _ => () }