docs(headers): Explain content_type assigned type
Explain why content_type mime params are not generic over slice. Related to #991
This commit is contained in:
committed by
Sean McArthur
parent
1868f8548d
commit
b64665635f
@@ -3,7 +3,7 @@ use mime::Mime;
|
|||||||
header! {
|
header! {
|
||||||
/// `Content-Type` header, defined in
|
/// `Content-Type` header, defined in
|
||||||
/// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5)
|
/// [RFC7231](http://tools.ietf.org/html/rfc7231#section-3.1.1.5)
|
||||||
///
|
///
|
||||||
/// The `Content-Type` header field indicates the media type of the
|
/// The `Content-Type` header field indicates the media type of the
|
||||||
/// associated representation: either the representation enclosed in the
|
/// associated representation: either the representation enclosed in the
|
||||||
/// message payload or the selected representation, as determined by 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,
|
/// format and how that data is intended to be processed by a recipient,
|
||||||
/// within the scope of the received message semantics, after any content
|
/// within the scope of the received message semantics, after any content
|
||||||
/// codings indicated by Content-Encoding are decoded.
|
/// 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
|
/// # ABNF
|
||||||
/// ```plain
|
/// ```plain
|
||||||
/// Content-Type = media-type
|
/// Content-Type = media-type
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// # Example values
|
/// # Example values
|
||||||
/// * `text/html; charset=ISO-8859-4`
|
/// * `text/html; charset=ISO-8859-4`
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use hyper::header::{Headers, ContentType};
|
/// use hyper::header::{Headers, ContentType};
|
||||||
/// use hyper::mime::{Mime, TopLevel, SubLevel};
|
/// use hyper::mime::{Mime, TopLevel, SubLevel};
|
||||||
///
|
///
|
||||||
/// let mut headers = Headers::new();
|
/// let mut headers = Headers::new();
|
||||||
///
|
///
|
||||||
/// headers.set(
|
/// headers.set(
|
||||||
/// ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![]))
|
/// ContentType(Mime(TopLevel::Text, SubLevel::Html, vec![]))
|
||||||
/// );
|
/// );
|
||||||
@@ -34,9 +38,9 @@ header! {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use hyper::header::{Headers, ContentType};
|
/// use hyper::header::{Headers, ContentType};
|
||||||
/// use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
/// use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
|
||||||
///
|
///
|
||||||
/// let mut headers = Headers::new();
|
/// let mut headers = Headers::new();
|
||||||
///
|
///
|
||||||
/// headers.set(
|
/// headers.set(
|
||||||
/// ContentType(Mime(TopLevel::Application, SubLevel::Json,
|
/// ContentType(Mime(TopLevel::Application, SubLevel::Json,
|
||||||
/// vec![(Attr::Charset, Value::Utf8)]))
|
/// vec![(Attr::Charset, Value::Utf8)]))
|
||||||
|
|||||||
Reference in New Issue
Block a user