[][src]Struct http_types::mime::Mime

pub struct Mime { /* fields omitted */ }

An IANA media type.

use http_types::Mime;
use std::str::FromStr;

let mime = Mime::from_str("text/html;charset=utf-8").unwrap();
assert_eq!(mime.essence(), "text/html");
assert_eq!(mime.param("charset").unwrap(), "utf-8");

Implementations

impl Mime[src]

pub fn sniff(bytes: &[u8]) -> Result<Self>[src]

Sniff the mime type from a byte slice.

pub fn from_extension(extension: impl AsRef<str>) -> Option<Self>[src]

Guess the mime type from a file extension

pub fn basetype(&self) -> &str[src]

Access the Mime's type value.

According to the spec this method should be named type, but that's a reserved keyword in Rust so hence prefix with base instead.

pub fn subtype(&self) -> &str[src]

Access the Mime's subtype value.

pub fn essence(&self) -> &str[src]

Access the Mime's essence value.

pub fn param(&self, name: impl Into<ParamName>) -> Option<&ParamValue>[src]

Get a reference to a param.

pub fn remove_param(&mut self, name: impl Into<ParamName>) -> Option<ParamValue>[src]

Remove a param from the set. Returns the ParamValue if it was contained within the set.

Trait Implementations

impl Clone for Mime[src]

impl Debug for Mime[src]

impl Display for Mime[src]

impl Eq for Mime[src]

impl From<&'_ Mime> for HeaderValue[src]

impl<'a> From<&'a str> for Mime[src]

impl From<MediaTypeProposal> for Mime[src]

impl From<Mime> for ContentType[src]

impl From<Mime> for MediaTypeProposal[src]

impl From<Mime> for HeaderValue[src]

impl FromStr for Mime[src]

type Err = Error

The associated error which can be returned from parsing.

pub fn from_str(s: &str) -> Result<Self, Self::Err>[src]

Create a new Mime.

Follows the WHATWG MIME parsing algorithm.

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

impl PartialEq<Mime> for ContentType[src]

impl PartialEq<Mime> for MediaTypeProposal[src]

impl PartialEq<Mime> for &MediaTypeProposal[src]

impl PartialEq<Mime> for Mime[src]

impl StructuralEq for Mime[src]

impl StructuralPartialEq for Mime[src]

impl ToHeaderValues for Mime[src]

type Iter = IntoIter<HeaderValue>

Returned iterator over header values which this type may correspond to.

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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>,