pub struct Mime { /* private fields */ }
Expand description
A parsed mime or media type.
Implementations§
Source§impl 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>>
pub fn get_param<'a, N>(&'a self, attr: N) -> Option<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 essence_str(&self) -> &str
pub fn essence_str(&self) -> &str
Return a &str
of the Mime’s “essence”.
Trait Implementations§
Source§impl Ord for Mime
impl Ord for Mime
Source§impl PartialOrd for Mime
impl PartialOrd for Mime
impl Eq 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