Macro rustful::content_type
[−]
[src]
macro_rules! content_type { ($main_type:tt / $sub_type:tt) => { ... }; ($main_type:tt / $sub_type:tt; $($param:tt = $value:tt);+) => { ... }; (@__rustful_to_expr $e: expr) => { ... }; }
A macro for making content types.
It takes a main type, a sub type and a parameter list. Instead of this:
use rustful::header::ContentType; use rustful::mime::{Mime, TopLevel, SubLevel, Attr, Value}; ContentType( Mime ( TopLevel::Text, SubLevel::Html, vec![(Attr::Charset, Value::Utf8)] ) );
it can be written like this:
#[macro_use(content_type)] extern crate rustful; use rustful::header::ContentType; ContentType(content_type!(Text / Html; Charset = Utf8));
The Charset = Utf8
part defines the parameter list for the content type and
may contain more than one parameter, or be omitted. Here are some more
examples showing that and how strings can be used for more exotic values:
#[macro_use(content_type)] extern crate rustful; use rustful::header::ContentType; ContentType(content_type!(Application / "octet-stream"; "type" = "image/gif"; "padding" = "4"));
#[macro_use(content_type)] extern crate rustful; use rustful::header::ContentType; ContentType(content_type!(Image / Png));