Struct ContentType
pub struct ContentType(/* private fields */);
Expand description
Content-Type
header, defined in
RFC7231
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
message semantics. The indicated media type defines both the data
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
Content-Type = media-type
§Example values
text/html; charset=utf-8
application/json
§Examples
use rama_http_headers::ContentType;
let ct = ContentType::json();
Implementations§
§impl ContentType
impl ContentType
pub fn json() -> ContentType
pub fn json() -> ContentType
A constructor to easily create a Content-Type: application/json
header.
pub fn text() -> ContentType
pub fn text() -> ContentType
A constructor to easily create a Content-Type: text/plain
header.
pub fn text_utf8() -> ContentType
pub fn text_utf8() -> ContentType
A constructor to easily create a Content-Type: text/plain; charset=utf-8
header.
pub fn text_event_stream() -> ContentType
pub fn text_event_stream() -> ContentType
A constructor to easily create a Content-Type: text/event-stream
header.
pub fn html() -> ContentType
pub fn html() -> ContentType
A constructor to easily create a Content-Type: text/html
header.
pub fn html_utf8() -> ContentType
pub fn html_utf8() -> ContentType
A constructor to easily create a Content-Type: text/html; charset=utf-8
header.
pub fn css() -> ContentType
pub fn css() -> ContentType
A constructor to easily create a Content-Type: text/css
header.
pub fn css_utf8() -> ContentType
pub fn css_utf8() -> ContentType
A constructor to easily create a text/css; charset=utf-8
header.
pub fn xml() -> ContentType
pub fn xml() -> ContentType
A constructor to easily create a Content-Type: text/xml
header.
pub fn csv() -> ContentType
pub fn csv() -> ContentType
A constructor to easily create a Content-Type: text/csv
header.
pub fn csv_utf8() -> ContentType
pub fn csv_utf8() -> ContentType
A constructor to easily create a Content-Type: text/csv; charset=utf-8
header.
pub fn form_url_encoded() -> ContentType
pub fn form_url_encoded() -> ContentType
A constructor to easily create a Content-Type: application/www-form-url-encoded
header.
pub fn jpeg() -> ContentType
pub fn jpeg() -> ContentType
A constructor to easily create a Content-Type: image/jpeg
header.
pub fn png() -> ContentType
pub fn png() -> ContentType
A constructor to easily create a Content-Type: image/png
header.
pub fn octet_stream() -> ContentType
pub fn octet_stream() -> ContentType
A constructor to easily create a Content-Type: application/octet-stream
header.
pub fn javascript() -> ContentType
pub fn javascript() -> ContentType
A constructor to easily create a Content-Type: application/javascript
header.
pub fn javascript_utf8() -> ContentType
pub fn javascript_utf8() -> ContentType
A constructor to easily create a Content-Type: application/javascript; charset=utf-8
header.
pub fn jose_json() -> ContentType
pub fn jose_json() -> ContentType
A constructor to easily create a Content-Type: application/jose+json
header.
Trait Implementations§
§impl Clone for ContentType
impl Clone for ContentType
§fn clone(&self) -> ContentType
fn clone(&self) -> ContentType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ContentType
impl Debug for ContentType
§impl Display for ContentType
impl Display for ContentType
§impl From<ContentType> for Mime
impl From<ContentType> for Mime
§fn from(ct: ContentType) -> Mime
fn from(ct: ContentType) -> Mime
§impl From<Mime> for ContentType
impl From<Mime> for ContentType
§fn from(m: Mime) -> ContentType
fn from(m: Mime) -> ContentType
§impl FromStr for ContentType
impl FromStr for ContentType
§impl HeaderDecode for ContentType
impl HeaderDecode for ContentType
§fn decode<'i, I>(values: &mut I) -> Result<ContentType, Error>where
I: Iterator<Item = &'i HeaderValue>,
fn decode<'i, I>(values: &mut I) -> Result<ContentType, Error>where
I: Iterator<Item = &'i HeaderValue>,
HeaderValue
s.§impl HeaderEncode for ContentType
impl HeaderEncode for ContentType
§fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
fn encode<E>(&self, values: &mut E)where
E: Extend<HeaderValue>,
HeaderValue
, and add it to a container
which has HeaderValue
type as each element. Read more§fn encode_to_value(&self) -> HeaderValue
fn encode_to_value(&self) -> HeaderValue
HeaderValue
.§impl PartialEq for ContentType
impl PartialEq for ContentType
§impl TypedHeader for ContentType
impl TypedHeader for ContentType
§fn name() -> &'static HeaderName
fn name() -> &'static HeaderName
impl StructuralPartialEq for ContentType
Auto Trait Implementations§
impl Freeze for ContentType
impl RefUnwindSafe for ContentType
impl Send for ContentType
impl Sync for ContentType
impl Unpin for ContentType
impl UnwindSafe for ContentType
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.