[−][src]Struct mime::Mime
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: PartialOrd + AsRef<[Param]>> PartialOrd<Mime<T>> for Mime<T>
[src]
[+]
impl<T: PartialOrd + AsRef<[Param]>> PartialOrd<Mime<T>> for Mime<T>
impl<T: Ord + AsRef<[Param]>> Ord for Mime<T>
[src]
[+]
impl<T: Ord + AsRef<[Param]>> Ord for Mime<T>
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>
impl<T: Clone + AsRef<[Param]>> Clone for Mime<T>
[src]
[+]
impl<T: Clone + AsRef<[Param]>> Clone for Mime<T>
impl<T: Eq + AsRef<[Param]>> Eq for Mime<T>
[src]
impl<T: Eq + AsRef<[Param]>> Eq for Mime<T>
impl<T: Hash + AsRef<[Param]>> Hash for Mime<T>
[src]
[+]
impl<T: Hash + AsRef<[Param]>> Hash for Mime<T>
impl<T: Debug + AsRef<[Param]>> Debug for Mime<T>
[src]
[+]
impl<T: Debug + AsRef<[Param]>> Debug for Mime<T>
impl<T: AsRef<[Param]>> Display for Mime<T>
[src]
[+]
impl<T: AsRef<[Param]>> Display for Mime<T>
impl FromStr for Mime
[src]
[+]
impl FromStr for Mime
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
[−]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
[−]
impl<T> ToString for T where
T: Display + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
[−]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
[−]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
[−]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T
[src]
[−]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
[−]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
[−]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
[−]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
[−]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
[−]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
[−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
[−]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
[−]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
[−]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more