Struct slack_blocks::elems::radio::build::RadioBuilder[][src]

pub struct RadioBuilder<'a, T, A, O> { /* fields omitted */ }
Expand description

Radio Button builder

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

Required Methods

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

  • options
  • action_id

Example

use slack_blocks::{blocks::{Actions, Block},
                   compose::Opt,
                   elems::Radio};

let options = vec![Opt::builder().text_md(":joy:").value("joy").build(),
                   Opt::builder().text_md(":smirk:").value("smirk").build(),];

let radio = Radio::builder().options(options)
                            .action_id("emoji_picker")
                            .build();

let block: Block =
  Actions::from_action_elements(std::iter::once(radio.into())).into();

// <send block to slack API>

Implementations

impl<'a, T, A, O> RadioBuilder<'a, T, A, O>[src]

pub fn new() -> Self[src]

Construct a new RadioBuilder

pub fn action_id<S>(
    self,
    action_id: S
) -> RadioBuilder<'a, T, Set<action_id>, O> where
    S: Into<Cow<'a, str>>, 
[src]

Sets action_id (Required)

An identifier for the action triggered when the radio button group is changed.

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 in the containing block. Maximum length for this field is 255 characters. [identify the source of the action 🔗]: https://api.slack.com/interactivity/handling#payloads

pub fn options<I, T2: Into<Text>>(
    self,
    options: I
) -> RadioBuilder<'a, T2, A, Set<options>> where
    I: IntoIterator<Item = Opt<'a, T2, NoUrl>>, 
[src]

Sets options (Required)

An array of [option objects 🔗].

A maximum of 10 options are allowed. [option objects 🔗]: https://api.slack.com/reference/block-kit/composition-objects#option

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

Sets confirm (Optional)

A confirm object 🔗 that defines an optional confirmation dialog that appears after clicking one of the radio buttons in this element.

impl<'a, A> RadioBuilder<'a, Plain, A, Set<options>>[src]

pub fn initial_option(self, option: Opt<'a, Plain, NoUrl>) -> Self[src]

Sets initial_option (Optional)

An option object 🔗 that exactly matches one of the options within options.

This option will be selected when the radio button group initially loads.

impl<'a, A> RadioBuilder<'a, Mrkdwn, A, Set<options>>[src]

pub fn initial_option(self, option: Opt<'a, Mrkdwn, NoUrl>) -> Self[src]

Sets initial_option (Optional)

An option object 🔗 that exactly matches one of the options within options.

This option will be selected when the radio button group initially loads.

impl<'a, T> RadioBuilder<'a, T, Set<action_id>, Set<options>>[src]

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

All done building, now give me a darn radio button group!

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

use slack_blocks::elems::Radio;

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

let foo = Radio::builder().action_id("bar")
                          .options(vec![Opt::builder().text_md("foo")
                                                      .value("bar")
                                                      .build()])
                          .build();

Trait Implementations

impl<'a, T: Debug, A: Debug, O: Debug> Debug for RadioBuilder<'a, T, A, O>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, T, A, O> RefUnwindSafe for RadioBuilder<'a, T, A, O> where
    A: RefUnwindSafe,
    O: RefUnwindSafe,
    T: RefUnwindSafe

impl<'a, T, A, O> Send for RadioBuilder<'a, T, A, O> where
    A: Send,
    O: Send,
    T: Send

impl<'a, T, A, O> Sync for RadioBuilder<'a, T, A, O> where
    A: Sync,
    O: Sync,
    T: Sync

impl<'a, T, A, O> Unpin for RadioBuilder<'a, T, A, O> where
    A: Unpin,
    O: Unpin,
    T: Unpin

impl<'a, T, A, O> UnwindSafe for RadioBuilder<'a, T, A, O> where
    A: UnwindSafe,
    O: UnwindSafe,
    T: 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.