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::builder().element(radio).build().into();

// <send block to slack API>

Implementations

Construct a new RadioBuilder

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.

Sets options (Required)

An array of option objects 🔗.

A maximum of 10 options are allowed.

Append an option to options

A maximum of 10 options are allowed.

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.

This is supported on crate feature blox only.

Allows using XML children to append options to the group.

Sets confirm (Optional)

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

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

This is supported on crate feature blox only.

Identity function

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.