From b64665635ff3a5dc7f47a2ed847d7a98e1f1eb67 Mon Sep 17 00:00:00 2001 From: derekdreery Date: Wed, 18 Jan 2017 00:05:54 +0000 Subject: [PATCH] docs(headers): Explain content_type assigned type Explain why content_type mime params are not generic over slice. Related to #991 --- src/header/common/content_type.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/header/common/content_type.rs b/src/header/common/content_type.rs index 73ead583..71596066 100644 --- a/src/header/common/content_type.rs +++ b/src/header/common/content_type.rs @@ -3,7 +3,7 @@ use mime::Mime; header! { /// `Content-Type` header, defined in /// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5) - /// + /// /// The `Content-Type` header field indicates the media type of the /// associated representation: either the representation enclosed in the /// message payload or the selected representation, as determined by the @@ -11,22 +11,26 @@ header! { /// format and how that data is intended to be processed by a recipient, /// within the scope of the received message semantics, after any content /// codings indicated by Content-Encoding are decoded. - /// + /// + /// Although the `mime` crate allows the mime options to be any slice, this crate + /// forces the use of Vec. This is to make sure the same header can't have more than 1 type. If + /// this is an issue, it's possible to implement `Header` on a custom struct. + /// /// # ABNF /// ```plain /// Content-Type = media-type /// ``` - /// + /// /// # Example values /// * `text/html; charset=ISO-8859-4` - /// + /// /// # Examples /// ``` /// use hyper::header::{Headers, ContentType}; /// use hyper::mime::{Mime, TopLevel, SubLevel}; - /// + /// /// let mut headers = Headers::new(); - /// + /// /// headers.set( /// ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![])) /// ); @@ -34,9 +38,9 @@ header! { /// ``` /// use hyper::header::{Headers, ContentType}; /// use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value}; - /// + /// /// let mut headers = Headers::new(); - /// + /// /// headers.set( /// ContentType(Mime(TopLevel::Application, SubLevel::Json, /// vec![(Attr::Charset, Value::Utf8)]))