From 45cf8c57c932a2756365748dc1e598ad3ee4b8ef Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 22 Mar 2018 13:30:18 -0700 Subject: [PATCH] feat(header): add `text()` and `text_utf8()` constructors to `ContentType` --- src/header/common/content_type.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/header/common/content_type.rs b/src/header/common/content_type.rs index 1aa1945614..899decc265 100644 --- a/src/header/common/content_type.rs +++ b/src/header/common/content_type.rs @@ -66,9 +66,23 @@ impl ContentType { ContentType(mime::APPLICATION_JSON) } + // Kind of deprecated, `text()` and `text_utf8()` are better. + // But don't bother with an actual #[deprecated], because the whole + // header system is changing in 0.12 anyways. + #[doc(hidden)] + pub fn plaintext() -> ContentType { + ContentType(mime::TEXT_PLAIN_UTF_8) + } + + /// A constructor to easily create a `Content-Type: text/plain` header. + #[inline] + pub fn text() -> ContentType { + ContentType(mime::TEXT_PLAIN_UTF_8) + } + /// A constructor to easily create a `Content-Type: text/plain; charset=utf-8` header. #[inline] - pub fn plaintext() -> ContentType { + pub fn text_utf8() -> ContentType { ContentType(mime::TEXT_PLAIN_UTF_8) }