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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)