Struct media_types::MediaType
[−]
[src]
pub struct MediaType { pub type_: Option<String>, pub tree: Option<String>, pub subtype: Option<String>, pub suffix: Option<String>, pub parameters: HashMap<String, String>, }
A Media Type commonly used to describe the contents of a resource.
Fields
type_: Option<String>
The top-level type or None
to match all types.
tree: Option<String>
A registration tree, the standards tree uses None
.
subtype: Option<String>
A subtype giving describing a concrete file format.
suffix: Option<String>
Some types use a suffix to refer to the base format like XML or JSON.
parameters: HashMap<String, String>
Media types can contain optional parameters for example for charsets or video codes.
Methods
impl MediaType
[src]
fn new(type_: Option<&str>, tree: Option<&str>, subtype: Option<&str>, suffix: Option<&str>) -> MediaType
Creates a new media type without parameters, they can be added later.
fn boundary(&self) -> Result<&str>
The boundary parameter is used to separate different blocks of multipart resources.
It is defined in RFC2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types #5.1. Multipart Media Type.
fn charset(&self) -> Result<Charset>
The charset parameter is defined for text/*
types, it carries information about the
charset.
The relevant RFCs are RFC2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types #4.1.2. Charset Parameter and RFC6657 - Update to MIME regarding "charset" Parameter Handling in Textual Media Types.
fn eq_mime_portion(&self, other: &MediaType) -> bool
Compares the mime type portion (the media type without parameters) of two media types.
fn ne_mime_portion(&self, other: &MediaType) -> bool
Returns true if the mime type portions differ, strict inverse of eq_mime_portion()
.
fn is_image_type(&self) -> bool
Checks if the media type is an image type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_audio_or_video_type(&self) -> bool
Checks if the media type is an audio or video type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_font_type(&self) -> bool
Checks if the media type is a font type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_zip_based_type(&self) -> bool
Checks if the media type is a zip based type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_archive_type(&self) -> bool
Checks if the media type is an archive type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_xml_type(&self) -> bool
Checks if the media type is an XML type.
Implements the MIME Sniffing standard for MIME type groups.
fn is_scriptable_mime_type(&self) -> bool
Checks if the media type is a scriptable type, HTML or PDF.
Implements the MIME Sniffing standard for MIME type groups.
Trait Implementations
impl PartialEq for MediaType
[src]
fn eq(&self, __arg_0: &MediaType) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &MediaType) -> bool
This method tests for !=
.
impl Eq for MediaType
[src]
impl Default for MediaType
[src]
impl Debug for MediaType
[src]
impl FromStr for MediaType
[src]
top-level type name / [ tree. ] subtype name [ +suffix ] [ ; parameters ]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self>
Parses a string s
to return a value of this type. Read more