Struct slack_blocks::blocks::Input [−][src]
pub struct Input<'a> { /* fields omitted */ }
Expand description
Input Block
A block that collects information from users -
Read slack’s guide to using modals 🔗 to learn how input blocks pass information to your app.
Implementations
impl<'a> Input<'a>
[src]
impl<'a> Input<'a>
[src]pub fn builder() -> InputBuilderInit<'a>
[src]
pub fn builder() -> InputBuilderInit<'a>
[src]Build a new input block
For example, see blocks::input::build::InputBuilder
.
pub fn from_label_and_element(
label: impl Into<Plain>,
element: impl Into<SupportedElement<'a>>
) -> Self
[src]
pub fn from_label_and_element(
label: impl Into<Plain>,
element: impl Into<SupportedElement<'a>>
) -> Self
[src]Create an Input Block from a text Label and interactive element.
Arguments
-
label
- A label that appears above an input element in the form of a text object 🔗 that must have type ofplain_text
. Maximum length for the text in this field is 2000 characters. -
element
- An interactiveblock_element
that will be used to gather the input for this block. For the kinds of Elements supported by Input blocks, see theSupportedElement
enum. For info about Block Elements in general, see theelems
module.
Example
use slack_blocks::elems::Select; use slack_blocks::blocks; let label = "On a scale from 1 - 5, how angsty are you?"; let input = Select::from_placeholder_and_action_id("Pick a channel...", "ABC123") .choose_from_public_channels(); let block = blocks::Input::from_label_and_element(label, input); // < send to slack API >
pub fn with_block_id(self, block_id: impl Into<Cow<'a, str>>) -> Self
[src]
pub fn with_block_id(self, block_id: impl Into<Cow<'a, str>>) -> Self
[src]Set a unique block_id
to identify this instance of an Input Block.
Arguments
block_id
- A string acting as a unique identifier for a block. You can use thisblock_id
when you receive an interaction payload to identify the source of the action 🔗. If not specified, one will be generated. Maximum length for this field is 255 characters.block_id
should be unique for each message and each iteration of a message. If a message is updated, use a newblock_id
.
Example
use slack_blocks::elems::Select; use slack_blocks::blocks; let label = "On a scale from 1 - 5, how angsty are you?"; let input = Select::from_placeholder_and_action_id("Pick a channel...", "ABC123") .choose_from_public_channels(); let block = blocks::Input ::from_label_and_element(label, input) .with_block_id("angst_rating_12345"); // < send to slack API >
pub fn with_hint(self, hint: impl Into<Plain>) -> Self
[src]
pub fn with_hint(self, hint: impl Into<Plain>) -> Self
[src]Set the hint
on this Input Block that appears below
an input element in a lighter grey.
Arguments
hint
- An optional hint that appears below an input element in a lighter grey. It must be a a text object 🔗 with atype
ofplain_text
. Maximum length for thetext
in this field is 2000 characters.
Example
use slack_blocks::elems::Select; use slack_blocks::blocks; let label = "On a scale from 1 - 5, how angsty are you?"; let input = Select::from_placeholder_and_action_id("Pick a channel...", "ABC123") .choose_from_public_channels(); let block = blocks::Input ::from_label_and_element(label, input) .with_hint("PSST hey! Don't let them know how angsty you are!"); // < send to slack API >
pub fn with_optional(self, optionality: bool) -> Self
[src]
pub fn with_optional(self, optionality: bool) -> Self
[src]Set whether or not this input is Optional.
Arguments
optionality
- A boolean that indicates whether the input element may be empty when a user submits the modal. Defaults to false.
Example
use slack_blocks::elems::Select; use slack_blocks::blocks; let label = "On a scale from 1 - 5, how angsty are you?"; let input = Select::from_placeholder_and_action_id("Pick a channel...", "ABC123") .choose_from_public_channels(); let block = blocks::Input ::from_label_and_element(label, input) .with_hint("PSST hey! Don't even answer that!") .with_optional(true); // < send to slack API >
pub fn dispatch_block_actions(self) -> Self
[src]
pub fn dispatch_block_actions(self) -> Self
[src]Will allow the elements in this block to dispatch block_actions payloads. Defaults to false.
pub fn validate(&self) -> Result<(), ValidationErrors>
[src]
pub fn validate(&self) -> Result<(), ValidationErrors>
[src]Validate that this Input block agrees with Slack’s model requirements
Errors
- If
from_label_and_element
was passed a Text object longer than 2000 chars - If
with_hint
was called with a block id longer than 2000 chars - If
with_block_id
was called with a block id longer than 256 chars
Example
use slack_blocks::elems::Select; use slack_blocks::blocks; let label = "On a scale from 1 - 5, how angsty are you?"; let input = Select::from_placeholder_and_action_id("Pick a channel...", "ABC123") .choose_from_public_channels(); let long_string = std::iter::repeat(' ').take(2001).collect::<String>(); let block = blocks::Input ::from_label_and_element(label, input) .with_block_id(long_string); assert_eq!(true, matches!(block.validate(), Err(_))); // < send to slack API >
Trait Implementations
impl<'de, 'a> Deserialize<'de> for Input<'a>
[src]
impl<'de, 'a> Deserialize<'de> for Input<'a>
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl<'a> StructuralPartialEq for Input<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Input<'a>
impl<'a> Send for Input<'a>
impl<'a> Sync for Input<'a>
impl<'a> Unpin for Input<'a>
impl<'a> UnwindSafe for Input<'a>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,