Skip to main content

EmbedFooterBuilder

Struct EmbedFooterBuilder 

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

Builds the footer of an embed — a text with an optional icon — for EmbedBuilder::footer.

A plain text converts into it, so .footer("Page 1") is enough when there is no icon. EmbedBuilder::build checks it as part of the embed; build checks it on its own.

discord.js counterpart: the EmbedFooterOptions passed to EmbedBuilder#setFooter.

§Examples

use djs_builders::{EmbedBuilder, EmbedFooterBuilder};

let embed = EmbedBuilder::new()
    .footer(EmbedFooterBuilder::new("Powered by djs-rs").icon_url("https://example.com/i.png"))
    .build()
    .unwrap();
assert_eq!(embed.footer.unwrap().icon_url.as_deref(), Some("https://example.com/i.png"));

Implementations§

Source§

impl EmbedFooterBuilder

Source

pub fn new(text: impl Into<CompactString>) -> Self

Creates a footer with text (at most 2048 characters).

discord.js counterpart: the text of EmbedFooterOptions, given to EmbedBuilder#setFooter.

Source

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

Sets the icon shown before the text: a link (http://, https://) or an uploaded file (attachment://name.png).

discord.js counterpart: the iconURL of EmbedFooterOptions.

Source

pub fn build(self) -> Result<EmbedFooter, ValidationError>

Checks the footer on its own and returns it; the paths in a ValidationError are text and icon_url.

discord.js counterpart: EmbedFooterOptions, checked by EmbedBuilder#setFooter.

§Errors

ValidationError::TooLong for a text above 2048 characters, ValidationError::InvalidUrl for an icon with a scheme Discord does not allow.

Source

pub fn build_unchecked(self) -> EmbedFooter

Returns the footer without any check (D-180).

discord.js counterpart: EmbedFooterOptions with validation off (disableValidators).

Trait Implementations§

Source§

impl Clone for EmbedFooterBuilder

Source§

fn clone(&self) -> Self

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 EmbedFooterBuilder

Source§

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

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

impl Eq for EmbedFooterBuilder

Source§

impl From<&String> for EmbedFooterBuilder

Source§

fn from(text: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for EmbedFooterBuilder

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
Source§

impl From<CompactString> for EmbedFooterBuilder

Source§

fn from(text: CompactString) -> Self

Converts to this type from the input type.
Source§

impl From<EmbedFooter> for EmbedFooterBuilder

Source§

fn from(footer: EmbedFooter) -> Self

Converts to this type from the input type.
Source§

impl From<String> for EmbedFooterBuilder

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for EmbedFooterBuilder

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EmbedFooterBuilder

Source§

fn eq(&self, other: &Self) -> 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 EmbedFooterBuilder

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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.