# Struct EmbedBuilder

> A rich embed, built with chained setters and sent with `MessageOptions::embed`:

`zaun_client::EmbedBuilder` · Struct

```rust
pub struct EmbedBuilder { … }
```

A rich embed, built with chained setters and sent with
`MessageOptions::embed`:

```rust
use zaun_client::{EmbedBuilder, MessageOptions, Picture};

let embed = EmbedBuilder::new()
    .title("Release 1.2")
    .url("https://example.com/releases/1.2")
    .description("What changed")
    .color(0x5865F2)
    .author("Release bot", None, Some(Picture::file("bot.png")))
    .field("Fixes", "12", true)
    .field("Features", "3", true)
    .image(Picture::file("screenshot.png"))
    .footer("zaun", None);
channel.send(MessageOptions::new().embed(embed))?;
```

## Methods

### `new`

```rust
pub fn new() -> Self
```

An empty embed. One needs a title, a description, an author, a footer, a picture or a
field to be sent.

### `title`

```rust
pub fn title<impl Into<String>>(self, title: impl Into<String>) -> Self
```

The title (1–256 characters).

### `description`

```rust
pub fn description<impl Into<String>>(self, description: impl Into<String>) -> Self
```

The text (1–4 096 characters).

### `url`

```rust
pub fn url<impl Into<String>>(self, url: impl Into<String>) -> Self
```

The title's link: `https://` only. A reader opens it by choice; nothing loads it.

### `color`

```rust
pub const fn color(self, color: u32) -> Self
```

The colour of its edge, `0xRRGGBB`.

### `timestamp`

```rust
pub const fn timestamp(self, ms: u64) -> Self
```

A time it shows, ms since the Unix epoch.

### `author`

```rust
pub fn author<impl Into<String>>(self, name: impl Into<String>, url: Option<&str>, icon: Option<Picture>) -> Self
```

The author line: a name (1–256 characters), a link (`https://`) and a small picture.

### `footer`

```rust
pub fn footer<impl Into<String>>(self, text: impl Into<String>, icon: Option<Picture>) -> Self
```

The footer line: a text (1–2 048 characters) and a small picture.

### `image`

```rust
pub fn image<impl Into<Picture>>(self, picture: impl Into<Picture>) -> Self
```

The large picture.

### `thumbnail`

```rust
pub fn thumbnail<impl Into<Picture>>(self, picture: impl Into<Picture>) -> Self
```

The small picture in the corner.

### `field`

```rust
pub fn field<impl Into<String>, impl Into<String>>(self, name: impl Into<String>, value: impl Into<String>, inline: bool) -> Self
```

Adds a field (name 1–256, value 1–1 024 characters; up to 25), shown beside the
neighbouring inline fields when `inline`.

### `to_embed`

```rust
pub fn to_embed(&self) -> Option<Embed>
```

The embed as the protocol has it, when no picture is left to upload.

### `check`

```rust
pub fn check(&self) -> Result<()>
```

Checks the embed against the protocol's rules (lengths, links, 25 fields, not empty),
as sending it would, without uploading anything.

# Errors
`Error::Protocol` naming the field and the rule.

## Trait implementations

`Clone`, `Debug`, `Default`, `Eq`, `From<Embed>`, `From<EmbedBuilder>`, `PartialEq`, `StructuralPartialEq`

[Full rustdoc page](/docs/api/rust/zaun-client/zaun_client/compose/embed/struct.EmbedBuilder.html)
