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) -> &str

Return a &str of 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

Auto Trait Implementations

impl Freeze for Mime

impl RefUnwindSafe for Mime

impl Send for Mime

impl Sync for Mime

impl Unpin for Mime

impl UnsafeUnpin for Mime

impl UnwindSafe for Mime

Blanket Implementations

impl<T> Any for Mime where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Mime where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Mime where T: ?Sized,

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

impl<T> CloneToUninit for Mime where T: Clone,

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

impl<T> From<T> for Mime

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Mime where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> ToString for Mime where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for Mime where U: From<T>,

fn into(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<U> for Mime where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Mime where U: TryFrom<T>,

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