[][src]Struct tide::http::content::ContentType

pub struct ContentType { /* fields omitted */ }

Indicate the media type of a resource's content.

MDN Documentation

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]

pub fn new<U>(media_type: U) -> ContentType where
    U: TryInto<Mime>,
    <U as TryInto<Mime>>::Error: Debug
[src]

Create a new instance.

pub fn from_headers(
    headers: impl AsRef<Headers>
) -> Result<Option<ContentType>, Error>
[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 Debug for ContentType[src]

impl From<Mime> for ContentType[src]

impl<'_> PartialEq<&'_ Mime> for ContentType[src]

impl PartialEq<Mime> for ContentType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,