Struct http_types::mime::Mime [−][src]
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]
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 From<MediaTypeProposal> for Mime[src]
impl From<MediaTypeProposal> for Mime[src]fn from(accept: MediaTypeProposal) -> Self[src]
impl PartialEq<&'_ Mime> for ContentType[src]
impl PartialEq<&'_ Mime> for ContentType[src]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 &MediaTypeProposal[src]
impl PartialEq<Mime> for &MediaTypeProposal[src]impl StructuralEq for Mime[src]
impl StructuralEq for Mime[src]impl StructuralPartialEq for Mime[src]
impl StructuralPartialEq for Mime[src]impl ToHeaderValues for Mime[src]
impl ToHeaderValues for Mime[src]type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
fn to_header_values(&self) -> Result<Self::Iter>[src]
Auto Trait Implementations
impl RefUnwindSafe for Mime
impl RefUnwindSafe for Mimeimpl UnwindSafe for Mime
impl UnwindSafe for MimeBlanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for Ttype Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,