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]
impl<'a, A> TextInputBuilder<'a, A>
[src]pub fn action_id(
self,
action_id: impl Into<Cow<'a, str>>
) -> TextInputBuilder<'a, Set<action_id>>
[src]
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_id
s in the containing block.
Maximum length for this field is 255 characters.
pub fn trigger_action_on(self, trigger: ActionTrigger) -> Self
[src]
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]
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]
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]
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]
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]
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]
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]
impl<'a> TextInputBuilder<'a, Set<action_id>>
[src]pub fn build(self) -> TextInput<'a>
[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 forTextInputBuilder
.
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
Auto Trait Implementations
impl<'a, A> RefUnwindSafe for TextInputBuilder<'a, A> where
A: RefUnwindSafe,
A: RefUnwindSafe,
impl<'a, A> Send for TextInputBuilder<'a, A> where
A: Send,
A: Send,
impl<'a, A> Sync for TextInputBuilder<'a, A> where
A: Sync,
A: Sync,
impl<'a, A> Unpin for TextInputBuilder<'a, A> where
A: Unpin,
A: Unpin,
impl<'a, A> UnwindSafe for TextInputBuilder<'a, A> where
A: UnwindSafe,
A: UnwindSafe,