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<StringString>,
}

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<StringString>

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>

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]

fn default() -> MediaType

Returns the "default value" for a type. Read more

impl Debug for MediaType
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

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

impl Display for MediaType
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.