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!"),
_ => ()
}
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
[−]
This method tests for !=
.
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s
to return a value of this type. Read more
Serializes this value into this serializer.
Deserialize this value given this Deserializer
.