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_idtext
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>
impl<'a, T, A> ButtonBuilder<'a, T, A>
Sourcepub fn style(self, style: Style) -> Self
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.
Sourcepub fn confirm(self, confirm: Confirm) -> Self
pub fn confirm(self, confirm: Confirm) -> Self
Set confirm (Optional)
A confirm object 🔗 that defines an optional confirmation dialog after the button is clicked.
Sourcepub fn url(self, url: impl Into<Cow<'a, str>>) -> Self
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.
Sourcepub fn value(self, value: impl Into<Cow<'a, str>>) -> Self
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.
Sourcepub fn action_id(
self,
action_id: impl Into<Cow<'a, str>>,
) -> ButtonBuilder<'a, T, Set<action_id>>
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.
Sourcepub fn child(self, text: impl Into<Plain>) -> ButtonBuilder<'a, Set<text>, A>
Available on crate feature blox only.
pub fn child(self, text: impl Into<Plain>) -> ButtonBuilder<'a, Set<text>, A>
blox only.Alias for text
Sourcepub fn text(self, text: impl Into<Plain>) -> ButtonBuilder<'a, Set<text>, A>
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>>
impl<'a> ButtonBuilder<'a, Set<text>, Set<action_id>>
Sourcepub fn build(self) -> Button<'a>
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 forButtonBuilder.
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();