Struct http_types::content::ContentType [−][src]
pub struct ContentType { /* fields omitted */ }Indicate the media type of a resource’s content.
Specifications
Examples
use http_types::content::ContentType; use http_types::{Response, Mime}; use std::str::FromStr; let content_type = ContentType::new("text/*"); let mut res = Response::new(200); content_type.apply(&mut res); let content_type = ContentType::from_headers(res)?.unwrap(); assert_eq!(content_type.value(), format!("{}", Mime::from_str("text/*")?).as_str());
Implementations
impl ContentType[src]
impl ContentType[src]pub fn new<U>(media_type: U) -> Self where
U: TryInto<Mime>,
U::Error: Debug, [src]
U: TryInto<Mime>,
U::Error: Debug,
Create a new instance.
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>[src]
Create a new instance from headers.
Content-Type headers can provide both full and partial URLs. In
order to always return fully qualified URLs, a base URL must be passed to
reference the current environment. In HTTP/1.1 and above this value can
always be determined from the request.
pub fn apply(&self, headers: impl AsMut<Headers>)[src]
Sets the header.
pub fn name(&self) -> HeaderName[src]
Get the HeaderName.
pub fn value(&self) -> HeaderValue[src]
Get the HeaderValue.
Trait Implementations
impl PartialEq<&'_ Mime> for ContentType[src]
impl PartialEq<&'_ Mime> for ContentType[src]Auto Trait Implementations
impl RefUnwindSafe for ContentType
impl RefUnwindSafe for ContentTypeimpl Send for ContentType
impl Send for ContentTypeimpl Sync for ContentType
impl Sync for ContentTypeimpl Unpin for ContentType
impl Unpin for ContentTypeimpl UnwindSafe for ContentType
impl UnwindSafe for ContentType