Struct slack_blocks::elems::button::build::ButtonBuilder[][src]

pub struct ButtonBuilder<'a, Text, ActionId> { /* fields omitted */ }
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::BlockElement = elems::Button::builder().text("do stuff!")
                                                          .action_id("stuff")
                                                          .build()
                                                          .into();
let block: blocks::Block =
  blocks::Actions::try_from(button).expect("Actions block supports buttons")
                                   .into();

Implementations

impl<'a, T, A> ButtonBuilder<'a, T, A>[src]

pub fn new() -> Self[src]

Construct a new button builder

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

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.

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

Set confirm (Optional)

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

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

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.

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

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.

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

Set text (Required)

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

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

impl<'a> ButtonBuilder<'a, Set<text>, Set<action_id>>[src]

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

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

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

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.