Struct slack_blocks::elems::select::public_channel::build::PublicChannelBuilder[][src]

pub struct PublicChannelBuilder<'a, Multi, Placeholder, ActionId> { /* fields omitted */ }
Expand description

PublicChannel Select builder

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

Required Methods

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

  • placeholder
  • action_id

NOTE: I’m experimenting with an API that deviates from the from_foo_and_bar. If you’re a user of this library, please give me feedback in the repository as to which pattern you like more. This will most likely be the new builder pattern for every structure in this crate.

Example

use std::convert::TryFrom;

use slack_blocks::{blocks::{Actions, Block},
                   compose::Opt,
                   elems::{select::PublicChannel, BlockElement}};

let select =
  PublicChannel::builder().placeholder("Choose your favorite channel!")
                          .action_id("favorite_channel")
                          .build();

let block: Block = Actions::builder().element(select).build().into();

// <send block to API>

Implementations

Construct a new PublicChannelBuilder

Set placeholder (Required)

A plain_text only text object 🔗 that defines the placeholder text shown on the menu. Maximum length for the text in this field is 150 characters.

Set action_id (Required)

An identifier for the action triggered when a menu option is selected. 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.

Set confirm (Optional)

A confirm object 🔗 that defines an optional confirmation dialog that appears after a menu item is selected.

Set initial_channel (Optional)

The ID of any valid conversation to be pre-selected when the menu loads.

If default_to_current_conversation is called, this will take precedence.

Set initial_channel (Optional, exclusive with initial_channel_current)

A collection of IDs of any valid conversations to be pre-selected when the menu loads.

Set max_selected_items (Optional)

Specifies the maximum number of items that can be selected in the menu.

Minimum number is 1.

All done building, now give me a darn select element!

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

use slack_blocks::elems::select::PublicChannel;

let sel = PublicChannel::builder().build(); // Won't compile!
use slack_blocks::elems::select::PublicChannel;

let sel = PublicChannel::builder().placeholder("foo")
                                  .action_id("bar")
                                  .build();

All done building, now give me a darn select element!

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

use slack_blocks::elems::select;

let sel = select::multi::PublicChannel::builder().build(); // Won't compile!
use slack_blocks::elems::select;

let sel = select::multi::PublicChannel::builder().placeholder("foo")
                                                 .action_id("bar")
                                                 .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.