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
impl Mime
impl Mime
pub 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
pub 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.
pub 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.
pub 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
impl<'_> From<&'_ Mime> for HeaderValue
impl<'_> From<&'_ Mime> for HeaderValue
fn from(mime: &Mime) -> HeaderValue
fn from(mime: &Mime) -> HeaderValue
Converts to this type from the input type.
impl From<MediaTypeProposal> for Mime
impl From<MediaTypeProposal> for Mime
fn from(accept: MediaTypeProposal) -> Mime
fn from(accept: MediaTypeProposal) -> Mime
Converts to this type from the input type.
impl From<Mime> for ContentType
impl From<Mime> for ContentType
fn from(media_type: Mime) -> ContentType
fn from(media_type: Mime) -> ContentType
Converts to this type from the input type.
impl From<Mime> for HeaderValue
impl From<Mime> for HeaderValue
fn from(mime: Mime) -> HeaderValue
fn from(mime: Mime) -> HeaderValue
Converts to this type from the input type.
impl From<Mime> for MediaTypeProposal
impl From<Mime> for MediaTypeProposal
fn from(media_type: Mime) -> MediaTypeProposal
fn from(media_type: Mime) -> MediaTypeProposal
Converts to this type from the input type.
impl<'_> PartialEq<&'_ Mime> for ContentType
impl<'_> PartialEq<&'_ Mime> for ContentType
impl<'_> PartialEq<Mime> for &'_ MediaTypeProposal
impl<'_> PartialEq<Mime> for &'_ MediaTypeProposal
impl PartialEq<Mime> for ContentType
impl PartialEq<Mime> for ContentType
impl PartialEq<Mime> for MediaTypeProposal
impl PartialEq<Mime> for MediaTypeProposal
impl 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.
fn to_header_values(&self) -> Result<<Mime as ToHeaderValues>::Iter, Error>
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 · sourcefn borrow_mut(&mut self) -> &mut T
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more