mime::mime! [] [src]

macro_rules! mime {
    ($top:tt / $sub:tt) => (
        mime!($top / $sub;)
    );

    ($top:tt / $sub:tt ; $($attr:tt = $val:tt),*) => (
        $crate::Mime(
            __mime__ident_or_ext!(TopLevel::$top),
            __mime__ident_or_ext!(SubLevel::$sub),
            vec![ $((__mime__ident_or_ext!(Attr::$attr), __mime__ident_or_ext!(Value::$val))),* ]
        )
    );
}

Easily create a Mime without having to import so many enums.

Example


let json = mime!(Application/Json);
let plain = mime!(Text/Plain; Charset=Utf8);
let text = mime!(Text/Html; Charset=("bar"), ("baz")=("quux"));
let img = mime!(Image/_);