# Struct Attachment

> A file on a message.

`zaun_client::Attachment` · Struct

```rust
pub struct Attachment { … }
```

A file on a message.

## Methods

### `id`

```rust
pub const fn id(&self) -> AttachmentId
```

Its id.

### `name`

```rust
pub fn name(&self) -> &str
```

Its name (empty when the cache does not have it).

### `size`

```rust
pub const fn size(&self) -> u64
```

Its size in bytes.

### `content_type`

```rust
pub fn content_type(&self) -> &str
```

Its media type.

### `data`

```rust
pub const fn data(&self) -> &AttachmentData
```

The attachment as the protocol describes it.

### `message`

```rust
pub const fn message(&self) -> &Message
```

The message it is on.

### `download`

```rust
pub fn download<impl AsRef<Path>>(&self, dest: impl AsRef<Path>) -> Result<PathBuf>
```

Downloads the file into the folder `dest` under a safe name and answers its path,
once its size and SHA3-256 match.

# Errors
The host refused, the transfer failed or timed out, or the file does not match.

## Trait implementations

`Clone`, `Debug`, `From<&Attachment>`

[Full rustdoc page](/docs/api/rust/zaun-client/zaun_client/objects/struct.Attachment.html)
