---
title: Mime
summary: A parsed mime or media type.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/mime/struct.Mime/
---

**Kind:** Struct  
**Module:** [mime](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/mime/)  
**Package:** fastly 0.13.1

```rust
pub struct Mime { /* private fields */ }
```

A parsed mime or media type.

## Methods

### essence_str

```rust
fn essence_str(&self) -> &str
```

Return a `&str` of the Mime's ["essence"](https://mimesniff.spec.whatwg.org/#mime-type-essence).

**Parameters**

- `self`: `&Self`

**Returns**

`&str`

### get_param

```rust
fn get_param<'a, N>(&'a self, attr: N) -> Option<Name<'a>>
where
    N: PartialEq<Name<'a>>,
```

Look up a parameter by name.

#### Example

```rust
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");
```

**Parameters**

- `self`: `&Self`
- `attr`: `N`

**Returns**

`Option<Name>`

### params

```rust
fn params<'a>(&'a self) -> Params<'a>
```

Returns an iterator over the parameters.

**Parameters**

- `self`: `&Self`

**Returns**

`Params`

### subtype

```rust
fn subtype(&self) -> Name<'_>
```

Get the subtype of this `Mime`.

#### Example

```rust
let mime = mime::TEXT_PLAIN;
assert_eq!(mime.subtype(), "plain");
assert_eq!(mime.subtype(), mime::PLAIN);
```

**Parameters**

- `self`: `&Self`

**Returns**

`Name`

### suffix

```rust
fn suffix(&self) -> Option<Name<'_>>
```

Get an optional +suffix for this `Mime`.

#### Example

```rust
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());
```

**Parameters**

- `self`: `&Self`

**Returns**

`Option<Name>`

### type_

```rust
fn type_(&self) -> Name<'_>
```

Get the top level media type for this `Mime`.

#### Example

```rust
let mime = mime::TEXT_PLAIN;
assert_eq!(mime.type_(), "text");
assert_eq!(mime.type_(), mime::TEXT);
```

**Parameters**

- `self`: `&Self`

**Returns**

`Name`

## Trait implementations

### impl AsRef<str> for Mime

#### as_ref

```rust
fn as_ref(&self) -> &str
```

**Parameters**

- `self`: `&Self`

**Returns**

`&str`

### impl Clone for Mime

#### clone

```rust
fn clone(&self) -> Self
```

**Parameters**

- `self`: `&Self`

**Returns**

`Self`

### impl Debug for Mime

#### fmt

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

**Parameters**

- `self`: `&Self`
- `f`: `&mut fmt::Formatter`

**Returns**

`fmt::Result`

### impl Display for Mime

#### fmt

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

**Parameters**

- `self`: `&Self`
- `f`: `&mut fmt::Formatter`

**Returns**

`fmt::Result`

### impl FromStr for Mime

#### from_str

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

**Parameters**

- `s`: `&str`

**Returns**

`Result<Mime, Self::Err>`

### impl Hash for Mime

#### hash

```rust
fn hash<T: Hasher>(&self, hasher: &mut T)
```

**Parameters**

- `self`: `&Self`
- `hasher`: `&mut T`

### impl Ord for Mime

#### cmp

```rust
fn cmp(&self, other: &Mime) -> Ordering
```

**Parameters**

- `self`: `&Self`
- `other`: `&Mime`

**Returns**

`Ordering`

### impl PartialEq for Mime

#### eq

```rust
fn eq(&self, other: &Mime) -> bool
```

**Parameters**

- `self`: `&Self`
- `other`: `&Mime`

**Returns**

`bool`

### impl PartialEq<&str> for Mime

#### eq

```rust
fn eq(&self, s: &&'a str) -> bool
```

**Parameters**

- `self`: `&Self`
- `s`: `&&str`

**Returns**

`bool`

### impl PartialOrd for Mime

#### partial_cmp

```rust
fn partial_cmp(&self, other: &Mime) -> Option<Ordering>
```

**Parameters**

- `self`: `&Self`
- `other`: `&Mime`

**Returns**

`Option<Ordering>`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `From<T>`
- `Into<U>`
- `ToOwned`
- `ToString`
- `TryFrom<U>`
- `TryInto<U>`
