pub struct Mime { /* private fields */ }Expand description
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
sourceimpl Mime
impl Mime
sourcepub fn from_extension(extension: impl AsRef<str>) -> Option<Mime>
pub fn from_extension(extension: impl AsRef<str>) -> Option<Mime>
Guess the mime type from a file extension
sourcepub fn basetype(&self) -> &str
pub fn basetype(&self) -> &str
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.
sourcepub fn param(&self, name: impl Into<ParamName>) -> Option<&ParamValue>
pub fn param(&self, name: impl Into<ParamName>) -> Option<&ParamValue>
Get a reference to a param.
sourcepub fn remove_param(&mut self, name: impl Into<ParamName>) -> Option<ParamValue>
pub fn remove_param(&mut self, name: impl Into<ParamName>) -> Option<ParamValue>
Remove a param from the set. Returns the ParamValue if it was contained within the set.
Trait Implementations
sourceimpl From<&'_ Mime> for HeaderValue
impl From<&'_ Mime> for HeaderValue
sourcepub fn from(mime: &Mime) -> HeaderValue
pub fn from(mime: &Mime) -> HeaderValue
Performs the conversion.
sourceimpl From<MediaTypeProposal> for Mime
impl From<MediaTypeProposal> for Mime
sourcepub fn from(accept: MediaTypeProposal) -> Mime
pub fn from(accept: MediaTypeProposal) -> Mime
Performs the conversion.
sourceimpl From<Mime> for HeaderValue
impl From<Mime> for HeaderValue
sourcepub fn from(mime: Mime) -> HeaderValue
pub fn from(mime: Mime) -> HeaderValue
Performs the conversion.
sourceimpl ToHeaderValues for Mime
impl ToHeaderValues for Mime
type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
sourcepub fn to_header_values(&self) -> Result<<Mime as ToHeaderValues>::Iter, Error>
pub fn to_header_values(&self) -> Result<<Mime as ToHeaderValues>::Iter, Error>
Converts this object to an iterator of resolved HeaderValues.
impl Eq for Mime
impl StructuralEq for Mime
impl StructuralPartialEq for Mime
Auto Trait Implementations
impl RefUnwindSafe for Mime
impl Send for Mime
impl Sync for Mime
impl Unpin for Mime
impl UnwindSafe for Mime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more