MimeType

Enum MimeType 

Source
pub enum MimeType {
Show 75 variants Other(String), Blob, Aac, Flac, Midi, Mp3, Oga, Opus, Wav, Weba, Avi, Mp4, Mpeg, Ogv, Ts, WebmVideo, ThreeGp, ThreeG2, Apng, Avif, Bmp, Gif, Ico, Jpg, Png, Qoi, Svg, Tiff, Webp, Text, Css, Csv, Html, Javascript, Json, JsonLd, Xml, Pdf, Rtf, Arc, Bz, Bz2, Gz, Jar, Ogg, Rar, SevenZ, Tar, Zip, Eot, Otf, Ttf, Woff, Woff2, Abiword, Azw, Cda, Csh, Doc, Docx, Epub, Ics, Mpkg, Odp, Ods, Odt, Php, Ppt, Pptx, Sh, Vsd, Xhtml, Xls, Xlsx, Xul,
}
Expand description

A media type, conveniently parsed

Variants§

§

Other(String)

A mimetype we didn’t recognize

§

Blob

An unstructured binary blob (application/octet-stream)

§

Aac

AAC audio file (audio/aac)

§

Flac

FLAC audio file (audio/flac)

§

Midi

MIDI audio file (audio/midi)

§

Mp3

MP3 audio file (audio/mpeg)

§

Oga

OGG audio file (audio/ogg)

§

Opus

Opus audio file in Ogg container (audio/ogg)

§

Wav

Waveform Audio Format (audio/wav)

§

Weba

WEBM audio file (audio/webm)

§

Avi

AVI: Audio Video Interleave (video/x-msvideo)

§

Mp4

MP4 video file (video/mp4)

§

Mpeg

MPEG video file (video/mpeg)

§

Ogv

OGG video file (video/ogg)

§

Ts

MPEG transport stream (video/mp2t)

§

WebmVideo

WEBM video file (video/webm)

§

ThreeGp

3GPP audio/video container (video/3gpp)

§

ThreeG2

3GPP2 audio/video container (video/3gpp2)

§

Apng

Animated Portable Network Graphics (image/apng)

§

Avif

AVIF image (image/avif)

§

Bmp

Windows OS/2 Bitmap Graphics (image/bmp)

§

Gif

Graphics Interchange Format (image/gif)

§

Ico

Icon format (image/vnd.microsoft.icon)

§

Jpg

JPEG image (image/jpeg)

§

Png

Portable Network Graphics (image/png)

§

Qoi

Quite ok Image Format

§

Svg

Scalable Vector Graphics (image/svg+xml)

§

Tiff

Tagged Image File Format (image/tiff)

§

Webp

WEBP image (image/webp)

§

Text

Plain text (text/plain)

§

Css

Cascading Style Sheets (text/css)

§

Csv

Comma-separated values (text/csv)

§

Html

HyperText Markup Language (text/html)

§

Javascript

JavaScript (text/javascript)

§

Json

JSON format (application/json)

§

JsonLd

JSON-LD format (application/ld+json)

§

Xml

XML (application/xml)

§

Pdf

Adobe Portable Document Format (application/pdf)

§

Rtf

Rich Text Format (application/rtf)

§

Arc

Archive document, multiple files embedded (application/x-freearc)

§

Bz

BZip archive (application/x-bzip)

§

Bz2

BZip2 archive (application/x-bzip2)

§

Gz

GZip Compressed Archive (application/gzip)

§

Jar

Java Archive (application/java-archive)

§

Ogg

OGG (application/ogg)

§

Rar

RAR archive (application/vnd.rar)

§

SevenZ

7-zip archive (application/x-7z-compressed)

§

Tar

Tape Archive (application/x-tar)

§

Zip

ZIP archive (application/zip)

§

Eot

MS Embedded OpenType fonts (application/vnd.ms-fontobject)

§

Otf

OpenType font (font/otf)

§

Ttf

TrueType Font (font/ttf)

§

Woff

Web Open Font Format (font/woff)

§

Woff2

Web Open Font Format 2 (font/woff2)

§

Abiword

AbiWord document (application/x-abiword)

§

Azw

Amazon Kindle eBook format (application/vnd.amazon.ebook)

§

Cda

CD audio (application/x-cdf)

§

Csh

C-Shell script (application/x-csh)

§

Doc

Microsoft Word (application/msword)

§

Docx

Microsoft Word OpenXML (application/vnd.openxmlformats-officedocument.wordprocessingml.document)

§

Epub

Electronic publication (application/epub+zip)

§

Ics

iCalendar format (text/calendar)

§

Mpkg

Apple Installer Package (application/vnd.apple.installer+xml)

§

Odp

OpenDocument presentation (application/vnd.oasis.opendocument.presentation)

§

Ods

OpenDocument spreadsheet (application/vnd.oasis.opendocument.spreadsheet)

§

Odt

OpenDocument text document (application/vnd.oasis.opendocument.text)

§

Php

Hypertext Preprocessor (application/x-httpd-php)

§

Ppt

Microsoft PowerPoint (application/vnd.ms-powerpoint)

§

Pptx

Microsoft PowerPoint OpenXML (application/vnd.openxmlformats-officedocument.presentationml.presentation)

§

Sh

Bourne shell script (application/x-sh)

§

Vsd

Microsoft Visio (application/vnd.visio)

§

Xhtml

XHTML (application/xhtml+xml)

§

Xls

Microsoft Excel (application/vnd.ms-excel)

§

Xlsx

Microsoft Excel OpenXML (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)

§

Xul

XUL (application/vnd.mozilla.xul+xml)

Implementations§

Source§

impl MimeType

Source

pub const fn const_default() -> Self

Default::default, but const

Source§

impl MimeType

Source

pub fn from_header(s: &str) -> Result<Self, <Self as FromStr>::Err>

Parse a mimetype from a string that may contain whitespace or “;” parameters.

Parameters are discarded, write your own parser if you need them.

Source§

impl MimeType

Source

pub fn from_extension(ext: &str) -> Option<Self>

Try to guess a file’s mime type from its extension. ext should NOT start with a dot.

Source

pub fn extension(&self) -> Option<&'static str>

Get the extension we use for files with this type. Never includes a dot.

Source

pub fn is_text(&self) -> bool

Returns true if this MIME type is always plain text.

Trait Implementations§

Source§

impl Clone for MimeType

Source§

fn clone(&self) -> MimeType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MimeType

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for MimeType

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for MimeType

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for MimeType

Source§

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

Get a string representation of this mimetype.

The following always holds:

assert_eq!(MimeType::from(x.to_string()), x);

The following might not hold:

// MimeType::from(y).to_string() may not equal y
Source§

impl From<&MimeType> for String

Source§

fn from(value: &MimeType) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for MimeType

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for MimeType

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl FromStr for MimeType

Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

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

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for MimeType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MimeType

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for MimeType

Source§

impl StructuralPartialEq for MimeType

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,