Struct slack_blocks::elems::select::user::build::UserBuilder[][src]

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

User Select builder

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

Required Methods

UserBuilder::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::User, BlockElement}};

let select: BlockElement =
  User::builder().placeholder("Choose your favorite co-worker!")
                 .action_id("favorite_coworker")
                 .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> UserBuilder<'a, M, P, A>[src]

pub fn new() -> Self[src]

Construct a new UserBuilder

pub fn placeholder(
    self,
    text: impl Into<Plain>
) -> UserBuilder<'a, M, Set<placeholder>, A>
[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>>
) -> UserBuilder<'a, M, P, Set<action_id>>
[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.

impl<'a, P, A> UserBuilder<'a, Single, P, A>[src]

pub fn initial_user<S>(self, user: S) -> Self where
    S: Into<Cow<'a, str>>, 
[src]

Set initial_user (Optional)

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

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

pub fn initial_users<S>(self, users: S) -> Self where
    S: Into<Cow<'a, [String]>>, 
[src]

Set initial_users (Optional)

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

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> UserBuilder<'a, Single, Set<placeholder>, Set<action_id>>[src]

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

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

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

use slack_blocks::elems::select::User;

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

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

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

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

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

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

use slack_blocks::elems::select;

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

let sel = select::multi::User::builder().placeholder("foo")
                                        .action_id("bar")
                                        .build();

Trait Implementations

impl<'a, Multi: Debug, Placeholder: Debug, ActionId: Debug> Debug for UserBuilder<'a, Multi, Placeholder, ActionId>[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> RefUnwindSafe for UserBuilder<'a, Multi, Placeholder, ActionId> where
    ActionId: RefUnwindSafe,
    Multi: RefUnwindSafe,
    Placeholder: RefUnwindSafe

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

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

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

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