ButtonBuilder

Struct ButtonBuilder 

Source
pub struct ButtonBuilder<'a, Text, ActionId> { /* private fields */ }
Expand description

§Button Builder

Allows you to construct safely, with compile-time checks on required setter methods.

§Required Methods

ButtonBuilder::build() is only available if these methods have been called:

  • action_id
  • text
use std::convert::TryFrom;

use slack_blocks::{blocks, elems};

let button = elems::Button::builder().text("do stuff!")
                                     .action_id("stuff")
                                     .build();
let block: blocks::Block =
  blocks::Actions::builder().element(button).build().into();

Implementations§

Source§

impl<'a, T, A> ButtonBuilder<'a, T, A>

Source

pub fn new() -> Self

Construct a new button builder

Source

pub fn style(self, style: Style) -> Self

Set style (Optional)

Decorates buttons with alternative visual color schemes.

Use this option with restraint.

If this method is not called, the default button style will be used.

Source

pub fn confirm(self, confirm: Confirm) -> Self

Set confirm (Optional)

A confirm object 🔗 that defines an optional confirmation dialog after the button is clicked.

Source

pub fn url(self, url: impl Into<Cow<'a, str>>) -> Self

Set url (Optional)

A URL to load in the user’s browser when the button is clicked.

Maximum length for this field is 3000 characters.

If you’re using url, you’ll still receive an interaction payload and will need to send an acknowledgement response.

Source

pub fn value(self, value: impl Into<Cow<'a, str>>) -> Self

Set value (Optional)

Add a meaningful value to send back to your app when this button is clicked.

Maximum length for this field is 2000 characters.

Source

pub fn action_id( self, action_id: impl Into<Cow<'a, str>>, ) -> ButtonBuilder<'a, T, Set<action_id>>

Set action_id (Required)

An identifier for this action.

You can use this when you receive an interaction payload to identify the source of the action 🔗.

Should be unique among all other action_ids used elsewhere by your app.

Maximum length for this field is 255 characters.

Source

pub fn child(self, text: impl Into<Plain>) -> ButtonBuilder<'a, Set<text>, A>

Available on crate feature blox only.

Alias for text

Source

pub fn text(self, text: impl Into<Plain>) -> ButtonBuilder<'a, Set<text>, A>

Set text (Required)

A plain text object 🔗 that defines the button’s text.

Maximum length for the text in this field is 75 characters.

Source§

impl<'a> ButtonBuilder<'a, Set<text>, Set<action_id>>

Source

pub fn build(self) -> Button<'a>

All done building, now give me a darn button!

no method name 'build' found for struct 'ButtonBuilder<...>'? Make sure all required setter methods have been called. See docs for ButtonBuilder.

use slack_blocks::elems::Button;

let foo = Button::builder().build(); // Won't compile!
use slack_blocks::{compose::Opt, elems::Button};

let foo = Button::builder().action_id("foo").text("Do foo").build();

Trait Implementations§

Source§

impl<'a, Text: Debug, ActionId: Debug> Debug for ButtonBuilder<'a, Text, ActionId>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, Text, ActionId> Freeze for ButtonBuilder<'a, Text, ActionId>

§

impl<'a, Text, ActionId> RefUnwindSafe for ButtonBuilder<'a, Text, ActionId>
where Text: RefUnwindSafe, ActionId: RefUnwindSafe,

§

impl<'a, Text, ActionId> Send for ButtonBuilder<'a, Text, ActionId>
where Text: Send, ActionId: Send,

§

impl<'a, Text, ActionId> Sync for ButtonBuilder<'a, Text, ActionId>
where Text: Sync, ActionId: Sync,

§

impl<'a, Text, ActionId> Unpin for ButtonBuilder<'a, Text, ActionId>
where Text: Unpin, ActionId: Unpin,

§

impl<'a, Text, ActionId> UnwindSafe for ButtonBuilder<'a, Text, ActionId>
where Text: UnwindSafe, ActionId: UnwindSafe,

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> 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> IntoChild for T

Source§

fn into_child(self) -> Self

Available on crate feature blox only.
Identity function
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<T> ErasedDestructor for T
where T: 'static,