Skip to main content

EmbedBuilder

Struct EmbedBuilder 

Source
pub struct EmbedBuilder { /* private fields */ }
Expand description

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

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))?;

Implementations§

Source§

impl EmbedBuilder

Source

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.

Source

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

The title (1–256 characters).

Source

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

The text (1–4 096 characters).

Source

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

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

Source

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

The colour of its edge, 0xRRGGBB.

Source

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

A time it shows, ms since the Unix epoch.

Source

pub fn author( 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.

Source

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

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

Source

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

The large picture.

Source

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

The small picture in the corner.

Source

pub fn field( 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.

Source

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

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

Source

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§

Source§

impl Clone for EmbedBuilder

Source§

fn clone(&self) -> EmbedBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for EmbedBuilder

Source§

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

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

impl Default for EmbedBuilder

Source§

fn default() -> EmbedBuilder

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

impl Eq for EmbedBuilder

Source§

impl From<Embed> for EmbedBuilder

Source§

fn from(embed: Embed) -> Self

An embed as received (Message::embeds), to send again or change: its pictures stay the attachments it names.

Source§

impl From<EmbedBuilder> for MessageOptions

Source§

fn from(embed: EmbedBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<EmbedBuilder> for EditMessage

Source§

fn from(embed: EmbedBuilder) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for EmbedBuilder

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EmbedBuilder

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> CryptoSafe for T
where T: Send + Sync + Debug,

§

impl<T> CryptoSafe for T

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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