Struct slack_blocks::elems::select::external::build::ExternalBuilder[][src]

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

External Select builder

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

Required Methods

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

  • placeholder
  • action_id
  • options or option_groups

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::{elems::{select::External, BlockElement},
                   blocks::{Actions, Block},
                   compose::Opt};

let select: BlockElement =
  External::builder().placeholder("Choose your favorite programming language!")
                   .action_id("lang_chosen")
                   .build()
                   .into();

let block: Block =
  Actions::try_from(select).expect("actions supports select elements")
                           .into();

// <send block to API>

Implementations

impl<'a, M, P, A, O> ExternalBuilder<'a, M, P, A, O>[src]

pub fn new() -> Self[src]

Construct a new ExternalBuilder

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

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.

pub fn action_id(
    self,
    text: impl Into<Cow<'a, str>>
) -> ExternalBuilder<'a, M, P, Set<action_id>, O>
[src]

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.

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

Set confirm (Optional)

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

pub fn min_query_length(self, min: u64) -> Self[src]

Set min_query_length (Optional)

When the typeahead field is used, a request will be sent on every character change.

If you prefer fewer requests or more fully ideated queries, use the min_query_length attribute to tell Slack the fewest number of typed characters required before dispatch.

The default value is 3.

impl<'a, P, A, O> ExternalBuilder<'a, Multi, P, A, O>[src]

pub fn max_selected_items(self, max: u32) -> Self[src]

Set max_selected_items (Optional)

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

Minimum number is 1.

impl<'a, P, A> ExternalBuilder<'a, Multi, P, A, OptionalMethodNotCalled<initial_option>>[src]

pub fn initial_options<I>(
    self,
    options: I
) -> ExternalBuilder<'a, Multi, P, A, Set<initial_option>> where
    I: IntoIterator<Item = Opt<'a, Plain, NoUrl>>, 
[src]

Set initial_options (Optional)

An array of option objects 🔗 that exactly match one or more of the options loaded from the external data source.

These options will be selected when the menu initially loads.

pub fn initial_option_groups<I>(
    self,
    option_groups: I
) -> ExternalBuilder<'a, Multi, P, A, Set<initial_option>> where
    I: IntoIterator<Item = OptGroup<'a, Plain, NoUrl>>, 
[src]

Set initial_options (Optional)

An array of option objects 🔗 that exactly match one or more of the options loaded from the external data source.

These options will be selected when the menu initially loads.

impl<'a, P, A> ExternalBuilder<'a, Single, P, A, OptionalMethodNotCalled<initial_option>>[src]

pub fn initial_option(
    self,
    option: Opt<'a, Plain, NoUrl>
) -> ExternalBuilder<'a, Single, P, A, Set<initial_option>>
[src]

Set initial_option (Optional)

A single option that exactly matches one of the options loaded from the external data source.

This option will be selected when the menu initially loads.

pub fn initial_option_group(
    self,
    option_group: OptGroup<'a, Plain, NoUrl>
) -> ExternalBuilder<'a, Single, P, A, Set<initial_option>>
[src]

Set initial_option (Optional)

A single option group that exactly matches one of the option groups loaded from the external data source.

This option will be selected when the menu initially loads.

impl<'a, O> ExternalBuilder<'a, Single, Set<placeholder>, Set<action_id>, O>[src]

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

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

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

use slack_blocks::elems::select::External;

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

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

impl<'a, O> ExternalBuilder<'a, Multi, Set<placeholder>, Set<action_id>, O>[src]

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

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

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

use slack_blocks::elems::select::External;

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

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

Trait Implementations

impl<'a, Multi: Debug, Placeholder: Debug, ActionId: Debug, Options: Debug> Debug for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, Multi, Placeholder, ActionId, Options> RefUnwindSafe for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options> where
    ActionId: RefUnwindSafe,
    Multi: RefUnwindSafe,
    Options: RefUnwindSafe,
    Placeholder: RefUnwindSafe

impl<'a, Multi, Placeholder, ActionId, Options> Send for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options> where
    ActionId: Send,
    Multi: Send,
    Options: Send,
    Placeholder: Send

impl<'a, Multi, Placeholder, ActionId, Options> Sync for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options> where
    ActionId: Sync,
    Multi: Sync,
    Options: Sync,
    Placeholder: Sync

impl<'a, Multi, Placeholder, ActionId, Options> Unpin for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options> where
    ActionId: Unpin,
    Multi: Unpin,
    Options: Unpin,
    Placeholder: Unpin

impl<'a, Multi, Placeholder, ActionId, Options> UnwindSafe for ExternalBuilder<'a, Multi, Placeholder, ActionId, Options> where
    ActionId: UnwindSafe,
    Multi: UnwindSafe,
    Options: UnwindSafe,
    Placeholder: 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.