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§
Source§impl Mime
impl Mime
Sourcepub fn from_extension(extension: impl AsRef<str>) -> Option<Self>
pub fn from_extension(extension: impl AsRef<str>) -> Option<Self>
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§
Source§impl From<&Mime> for HeaderValue
impl From<&Mime> for HeaderValue
Source§impl From<MediaTypeProposal> for Mime
impl From<MediaTypeProposal> for Mime
Source§fn from(accept: MediaTypeProposal) -> Self
fn from(accept: MediaTypeProposal) -> Self
Converts to this type from the input type.
Source§impl From<Mime> for ContentType
impl From<Mime> for ContentType
Source§impl From<Mime> for HeaderValue
impl From<Mime> for HeaderValue
Source§impl From<Mime> for MediaTypeProposal
impl From<Mime> for MediaTypeProposal
Source§impl PartialEq<&Mime> for ContentType
impl PartialEq<&Mime> for ContentType
Source§impl PartialEq<Mime> for &MediaTypeProposal
impl PartialEq<Mime> for &MediaTypeProposal
Source§impl PartialEq<Mime> for ContentType
impl PartialEq<Mime> for ContentType
Source§impl PartialEq<Mime> for MediaTypeProposal
impl PartialEq<Mime> for MediaTypeProposal
Source§impl ToHeaderValues for Mime
impl ToHeaderValues for Mime
Source§type Iter = IntoIter<HeaderValue>
type Iter = IntoIter<HeaderValue>
Returned iterator over header values which this type may correspond to.
Source§fn to_header_values(&self) -> Result<Self::Iter>
fn to_header_values(&self) -> Result<Self::Iter>
Converts this object to an iterator of resolved
HeaderValues
.impl Eq for Mime
impl StructuralPartialEq for Mime
Auto Trait Implementations§
impl Freeze for Mime
impl RefUnwindSafe for Mime
impl Send for Mime
impl Sync for Mime
impl Unpin for Mime
impl UnwindSafe for Mime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more