Struct mime::Mime [] [src]

pub struct Mime(pub TopLevel, pub SubLevel, pub Vec<Param>);

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!"),
    _ => ()
}

Trait Implementations

impl Debug for Mime
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl PartialEq for Mime
[src]

fn eq(&self, __arg_0: &Mime) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Mime) -> bool

This method tests for !=.

impl Clone for Mime
[src]

fn clone(&self) -> Mime

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Display for Mime
[src]

fn fmt(&self, fmt: &mut Formatter) -> Result

Formats the value using the given formatter.

impl FromStr for Mime
[src]

type Err = ()

The associated error which can be returned from parsing.

fn from_str(raw: &str) -> Result<Mime()>

Parses a string s to return a value of this type. Read more