Struct slack_blocks::elems::select::SelectBuilder[][src]

pub struct SelectBuilder<'a> { /* fields omitted */ }
👎 Deprecated since 0.17.2:

use individual select builders instead

Expand description

Select Element Builder

Use to construct a Select element and easily choose a data source

Implementations

impl<'a> SelectBuilder<'a>[src]

pub fn from_placeholder_and_action_id(
    placeholder: impl Into<Plain>,
    action_id: impl Into<Cow<'a, str>>
) -> Self
[src]

Construct a Select block element from required parts

Arguments

  • placeholder: A [text object 🔗]

Example

See example for Select::from_placeholder_and_action_id

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

Construct a Select block element from required parts

Arguments

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

Example

use std::iter;
use std::convert::TryFrom;

use slack_blocks::{
  blocks::{Block, Actions},
  elems::{BlockElement, select::Select},
  compose::{text, Confirm, text::ToSlackPlaintext},
};


let confirm = Confirm::from_parts(
  "Are you sure?",
  "Think hard about this.".plaintext(),
  "Yes",
  "No",
);

let select: BlockElement = Select::from_placeholder_and_action_id("Pick a channel to delete!", "delete_chan_select")
                                  .with_confirm(confirm)
                                  .choose_from_public_channels()
                                  .into();

let block: Block = Actions::try_from(select).unwrap().into();

// < send `block` to slack API >

pub fn choose_from_public_channels(self) -> PublicChannel<'a>[src]

Turn the builder into a Public Channel select element

Example

use std::iter;
use std::convert::TryFrom;

use slack_blocks::{
  blocks::{Block, Section, Actions},
  elems::{BlockElement, select::Select},
  compose::{text, Confirm},
};


let confirm = Confirm::from_parts("Are you sure?", text::Mrkdwn::from("Think hard about this."), "Yes", "No");

let select: BlockElement = Select::from_placeholder_and_action_id("Pick a channel to delete!", "1234")
                                  .with_confirm(confirm)
                                  .choose_from_public_channels()
                                  .into();

let block: Block = Actions::try_from(select).unwrap().into();

// < send `block` to slack API >

pub fn choose_from_all_channels(self) -> Conversation<'a>[src]

Set the data source to “All conversations”. See docs for select::Conversation for more info.

Example

use std::iter;
use std::convert::TryFrom;

use slack_blocks::{
  blocks::{Block, Section, Actions},
  elems::{BlockElement, select::Select},
  compose::{text, Confirm},
};

use text::ToSlackPlaintext;


let select: BlockElement = Select::from_placeholder_and_action_id("Channel", "get_member_channel_select")
                                  .choose_from_all_channels()
                                  .into();

let blocks: Vec<Block> = vec![
  Section::from_text("Get the members of a channel".plaintext()).into(),
  Actions::try_from(select).unwrap().into(),
];

// <send `blocks` to slack's API>

pub fn choose_from_users(self) -> User<'a>[src]

Set the data source to “users”. See docs for select::User for more info.

Example

use std::{convert::TryFrom, iter};

use slack_blocks::{blocks::{Actions, Block, Section},
                   elems::{select::Select, BlockElement},
                   text,
                   text::ToSlackPlaintext};

let select: BlockElement =
  Select::from_placeholder_and_action_id("Choose a user to ban!!",
                                         "ban_chosen").choose_from_users()
                                                      .into();

let blocks: Block = Actions::try_from(select).unwrap().into();

// <send `blocks` to slack's API>

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

Users will choose from an external data source. See docs for select::External for more info.

Example

use std::iter;
use std::convert::TryFrom;

use slack_blocks::{
  text,
  text::ToSlackPlaintext,
  blocks::{Block, Section, Actions},
  elems::{BlockElement, select::Select},
};

let select: BlockElement = Select::from_placeholder_and_action_id("Pick your favorite cheese", "cheese_chosen")
                                  .choose_from_external()
                                  .into();

let blocks: Block = Actions::try_from(select).unwrap().into();

// <send `blocks` to slack's API>

Trait Implementations

impl<'a> Debug for SelectBuilder<'a>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> RefUnwindSafe for SelectBuilder<'a>

impl<'a> Send for SelectBuilder<'a>

impl<'a> Sync for SelectBuilder<'a>

impl<'a> Unpin for SelectBuilder<'a>

impl<'a> UnwindSafe for SelectBuilder<'a>

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.