pub struct Mime { /* private fields */ }
Expand description
A parsed mime or media type.
Implementations
sourceimpl Mime
impl Mime
sourcepub fn type_(&self) -> Name<'_>
pub fn type_(&self) -> Name<'_>
Get the top level media type for this Mime
.
Example
let mime = mime::TEXT_PLAIN;
assert_eq!(mime.type_(), "text");
assert_eq!(mime.type_(), mime::TEXT);
sourcepub fn subtype(&self) -> Name<'_>
pub fn subtype(&self) -> Name<'_>
Get the subtype of this Mime
.
Example
let mime = mime::TEXT_PLAIN;
assert_eq!(mime.subtype(), "plain");
assert_eq!(mime.subtype(), mime::PLAIN);
sourcepub fn suffix(&self) -> Option<Name<'_>>
pub fn suffix(&self) -> Option<Name<'_>>
Get an optional +suffix for this Mime
.
Example
let svg = "image/svg+xml".parse::<mime::Mime>().unwrap();
assert_eq!(svg.suffix(), Some(mime::XML));
assert_eq!(svg.suffix().unwrap(), "xml");
assert!(mime::TEXT_PLAIN.suffix().is_none());
sourcepub fn get_param<'a, N>(&'a self, attr: N) -> Option<Name<'a>> where
N: PartialEq<Name<'a>>,
pub fn get_param<'a, N>(&'a self, attr: N) -> Option<Name<'a>> where
N: PartialEq<Name<'a>>,
Look up a parameter by name.
Example
let mime = mime::TEXT_PLAIN_UTF_8;
assert_eq!(mime.get_param(mime::CHARSET), Some(mime::UTF_8));
assert_eq!(mime.get_param("charset").unwrap(), "utf-8");
assert!(mime.get_param("boundary").is_none());
let mime = "multipart/form-data; boundary=ABCDEFG".parse::<mime::Mime>().unwrap();
assert_eq!(mime.get_param(mime::BOUNDARY).unwrap(), "ABCDEFG");
sourcepub fn params<'a>(&'a self) -> Params<'a>ⓘNotable traits for Params<'a>impl<'a> Iterator for Params<'a> type Item = (Name<'a>, Name<'a>);
pub fn params<'a>(&'a self) -> Params<'a>ⓘNotable traits for Params<'a>impl<'a> Iterator for Params<'a> type Item = (Name<'a>, Name<'a>);
Returns an iterator over the parameters.
sourcepub fn essence_str(&self) -> &str
pub fn essence_str(&self) -> &str
Return a &str
of the Mime’s “essence”.
Trait Implementations
sourceimpl Ord for Mime
impl Ord for Mime
sourceimpl PartialOrd<Mime> for Mime
impl PartialOrd<Mime> for Mime
sourcefn partial_cmp(&self, other: &Mime) -> Option<Ordering>
fn partial_cmp(&self, other: &Mime) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq 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