pub struct MediaType(/* private fields */);Expand description
An IANA media type such as image/png, or a top-level type such as image.
The wrapper does not validate syntax; it provides normalization helpers used when matching provider capabilities. Comparison is case-sensitive on the stored string; callers should normalize before comparing.
Implementations§
Source§impl MediaType
impl MediaType
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consumes the media type and returns the inner String.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true when the value is a full type/subtype media type.
A wildcard subtype (image/*) is not considered full.
Sourcepub fn top_level(&self) -> String
pub fn top_level(&self) -> String
Returns the top-level type (image for image/png), lowercased.
Sourcepub fn subtype(&self) -> Option<&str>
pub fn subtype(&self) -> Option<&str>
Returns the subtype (png for image/png) without parameters, if any.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for MediaType
impl<'de> Deserialize<'de> for MediaType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for MediaType
Source§impl Ord for MediaType
impl Ord for MediaType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for MediaType
impl PartialOrd for MediaType
impl StructuralPartialEq for MediaType
Auto Trait Implementations§
impl Freeze for MediaType
impl RefUnwindSafe for MediaType
impl Send for MediaType
impl Sync for MediaType
impl Unpin for MediaType
impl UnsafeUnpin for MediaType
impl UnwindSafe for MediaType
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§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.