Struct Mime

struct Mime { ... }

A parsed mime or media type.

Implementations

impl Mime

fn type_(self: &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: &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: &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>(self: &'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>(self: &'a Self) -> Params<'a>

Returns an iterator over the parameters.

fn essence_str(self: &Self) -> &str

Return a &str of the Mime's "essence".

impl AsRef for Mime

fn as_ref(self: &Self) -> &str

impl Clone for Mime

fn clone(self: &Self) -> Mime

impl Debug for Mime

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Display for Mime

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for Mime

impl Freeze for Mime

impl FromStr for Mime

fn from_str(s: &str) -> Result<Mime, <Self as >::Err>

impl Hash for Mime

fn hash<T: Hasher>(self: &Self, hasher: &mut T)

impl Ord for Mime

fn cmp(self: &Self, other: &Mime) -> Ordering

impl PartialEq for Mime

fn eq(self: &Self, other: &Mime) -> bool

impl PartialOrd for Mime

fn partial_cmp(self: &Self, other: &Mime) -> Option<Ordering>

impl RefUnwindSafe for Mime

impl Send for Mime

impl Sync for Mime

impl Unpin for Mime

impl UnwindSafe for Mime

impl<'a> PartialEq for Mime

fn eq(self: &Self, s: &&'a str) -> bool

impl<T> Any for Mime

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Mime

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Mime

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Mime

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Mime

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Mime

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Mime

fn to_string(self: &Self) -> String

impl<T, U> Into for Mime

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Mime

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Mime

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>