Struct slack_blocks::elems::text_input::build::TextInputBuilder[][src]

pub struct TextInputBuilder<'a, A> { /* fields omitted */ }
Expand description

Build a Text Input element

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

Required Methods

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

  • action_id

Examples

use slack_blocks::{blocks::{Block, Input}, elems::TextInput};

let text_input = TextInput::builder()
                           .action_id("plate_num")
                           .placeholder("ABC1234")
                           .length(1..=7)
                           .build();

let block: Block = Input::from_label_and_element("enter custom license plate", text_input)
                         .dispatch_block_actions()
                         .into();

Implementations

impl<'a, A> TextInputBuilder<'a, A>[src]

pub fn new() -> Self[src]

Construct a new text input builder of empty state

pub fn action_id(
    self,
    action_id: impl Into<Cow<'a, str>>
) -> TextInputBuilder<'a, Set<action_id>>
[src]

Set action_id (Required)

An identifier for the input value when the parent modal is submitted.

You can use this when you receive a view_submission payload to identify the value of the input element 🔗.

Should be unique among all other action_ids in the containing block.

Maximum length for this field is 255 characters.

pub fn trigger_action_on(self, trigger: ActionTrigger) -> Self[src]

Add a new event trigger (Optional)

In messages, in order to receive events you must invoke this method and set dispatch_action to true on the containing Input block.

In modals and other contexts, the value of this element will be included with the submission of the form.

By invoking this with ActionTrigger::OnCharacterEntered, ActionTrigger::OnEnterPressed, or both, you can configure the input element to send additional events when these triggers are fired by the client.

For more info on these events, see block_actions interaction payload 🔗.

Examples

use slack_blocks::{blocks::{Block, Input}, elems::TextInput};

let text_input = TextInput::builder()
                           .action_id("plate_num")
                           .placeholder("ABC1234")
                           .length(1..=7)
                           .build();

let block: Block = Input::from_label_and_element("enter custom license plate", text_input)
                         .dispatch_block_actions()
                         .into();

pub fn placeholder(self, placeholder: impl Into<Plain>) -> Self[src]

Set placeholder (Optional)

A plain_text only text object 🔗 that defines the placeholder text shown in the plain-text input.

Maximum length for the text in this field is 150 characters.

pub fn initial_value(self, init: impl Into<Cow<'a, str>>) -> Self[src]

Set initial value (Optional)

The initial value in the plain-text input when it is loaded.

pub fn multiline(self) -> Self[src]

Set multiline to true (Optional)

Indicates that the input will be a larger textarea, rather than a single line.

pub fn min_length(self, min: u32) -> Self[src]

Set min_length (Optional)

The minimum length of input that the user must provide.

If the user provides less, they will receive an error.

Maximum value is 3000.

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

Set max_length (Optional)

The maximum length of input that the user can provide.

If the user provides more, they will receive an error.

pub fn length(self, rng: impl RangeBounds<u32>) -> Self[src]

Set min_length and/or max_length with a rust range literal (Optional)

use slack_blocks::elems::TextInput;

TextInput::builder().action_id("vanity_plate")
                    .placeholder("enter your desired custom license plate")
                    .length(1..=7);
use slack_blocks::elems::TextInput;

TextInput::builder().action_id("first_name")
                    .placeholder("enter your first name")
                    .length(2..);
use slack_blocks::elems::TextInput;

TextInput::builder()
          .action_id("does nothing")
          .placeholder("This is the same as not calling length at all!")
          .length(..);

impl<'a> TextInputBuilder<'a, Set<action_id>>[src]

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

All done building, now give me a darn text input!

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

use slack_blocks::elems::TextInput;

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

let sel = TextInput::builder().action_id("bar").build();

Trait Implementations

impl<'a, A: Debug> Debug for TextInputBuilder<'a, A>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, A> RefUnwindSafe for TextInputBuilder<'a, A> where
    A: RefUnwindSafe

impl<'a, A> Send for TextInputBuilder<'a, A> where
    A: Send

impl<'a, A> Sync for TextInputBuilder<'a, A> where
    A: Sync

impl<'a, A> Unpin for TextInputBuilder<'a, A> where
    A: Unpin

impl<'a, A> UnwindSafe for TextInputBuilder<'a, A> where
    A: 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.