Trait EmbedMessageBuilding

Source
pub trait EmbedMessageBuilding {
    // Required methods
    fn push_named_link(
        &mut self,
        name: impl Into<Content>,
        url: impl Into<Content>,
    ) -> &mut Self;
    fn push_named_link_safe(
        &mut self,
        name: impl Into<Content>,
        url: impl Into<Content>,
    ) -> &mut Self;
}
Expand description

A trait with additional functionality over the MessageBuilder for creating content with additional functionality available only in embeds.

Namely, this allows you to create named links via the non-escaping Self::push_named_link method and the escaping Self::push_named_link_safe method.

§Examples

Make a named link to Rust’s GitHub organization:

use serenity::utils::{EmbedMessageBuilding, MessageBuilder};

let msg = MessageBuilder::new()
    .push_named_link("Rust's GitHub", "https://github.com/rust-lang")
    .build();

assert_eq!(msg, "[Rust's GitHub](https://github.com/rust-lang)");

Required Methods§

Pushes a named link to a message, intended for use in embeds.

§Examples

Make a simple link to Rust’s homepage for use in an embed:

use serenity::utils::{EmbedMessageBuilding, MessageBuilder};

let mut msg = MessageBuilder::new();
msg.push("Rust's website: ");
msg.push_named_link("Homepage", "https://rust-lang.org");
let content = msg.build();

assert_eq!(content, "Rust's website: [Homepage](https://rust-lang.org)");

Pushes a named link intended for use in an embed, but with a normalized name to avoid escaping issues.

Refer to Self::push_named_link for more information.

§Examples
use serenity::utils::{EmbedMessageBuilding, MessageBuilder};

let mut msg = MessageBuilder::new();
msg.push("A weird website name: ");
msg.push_named_link_safe("Try to ] break links (](", "https://rust-lang.org");
let content = msg.build();

assert_eq!(content, "A weird website name: [Try to   break links ( (](https://rust-lang.org)");

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§