Struct mime::Mime [−][src]
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!"), _ => () }
Methods
impl<P: AsRef<[Param]>> Mime<P>
[src]
impl<P: AsRef<[Param]>> Mime<P>
Trait Implementations
impl<T: Clone + AsRef<[Param]>> Clone for Mime<T>
[src]
impl<T: Clone + AsRef<[Param]>> Clone for Mime<T>
fn clone(&self) -> Mime<T>
[src]
fn clone(&self) -> Mime<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Debug + AsRef<[Param]>> Debug for Mime<T>
[src]
impl<T: Debug + AsRef<[Param]>> Debug for Mime<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<LHS: AsRef<[Param]>, RHS: AsRef<[Param]>> PartialEq<Mime<RHS>> for Mime<LHS>
[src]
impl<LHS: AsRef<[Param]>, RHS: AsRef<[Param]>> PartialEq<Mime<RHS>> for Mime<LHS>
fn eq(&self, other: &Mime<RHS>) -> bool
[src]
fn eq(&self, other: &Mime<RHS>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<T: AsRef<[Param]>> Display for Mime<T>
[src]
impl<T: AsRef<[Param]>> Display for Mime<T>
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl FromStr for Mime
[src]
impl FromStr for Mime
type Err = ()
The associated error which can be returned from parsing.
fn from_str(raw: &str) -> Result<Mime, ()>
[src]
fn from_str(raw: &str) -> Result<Mime, ()>
Parses a string s
to return a value of this type. Read more
impl Serialize for Mime
[src]
impl Serialize for Mime
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where
S: Serializer,
Serializes this value into this serializer.
impl Deserialize for Mime
[src]
impl Deserialize for Mime
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error> where
D: Deserializer,
[src]
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error> where
D: Deserializer,
Deserialize this value given this Deserializer
.