Struct Mime
pub struct Mime { /* private fields */ }
A parsed mime or media type.
Implementations
impl Mime
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);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);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());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");fn params<'a>(&'a self) -> Params<'a>Returns an iterator over the parameters.
fn essence_str(&self) -> &strReturn a
&strof the Mime's "essence".
Trait Implementations
impl AsRef<str> for Mime
fn as_ref(&self) -> &str
impl Clone for Mime
fn clone(&self) -> Self
impl Debug for Mime
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Mime
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Mime
impl FromStr for Mime
type Err = FromStrError;fn from_str(s: &str) -> Result<Mime, Self::Err>
impl Hash for Mime
fn hash<T: Hasher>(&self, hasher: &mut T)
impl Ord for Mime
fn cmp(&self, other: &Mime) -> Ordering
impl PartialEq for Mime
fn eq(&self, other: &Mime) -> bool
impl PartialOrd for Mime
fn partial_cmp(&self, other: &Mime) -> Option<Ordering>
impl<'a> PartialEq<&'a str> for Mime
fn eq(&self, s: &&'a str) -> bool