InputBuilder

Struct InputBuilder 

Source
pub struct InputBuilder<'a, Element, Label> { /* private fields */ }
Expand description

Build an Input block

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

§Required Methods

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

  • element

§Example

use slack_blocks::{blocks::Input,
                   compose::text::ToSlackPlaintext,
                   elems::TextInput};

let block =
  Input::builder().label("foo".plaintext())
                  .element(TextInput::builder().action_id("foo").build())
                  .build();

Implementations§

Source§

impl<'a, E, L> InputBuilder<'a, E, L>

Source

pub fn new() -> Self

Create a new InputBuilder

Source

pub fn label<T>(self, label: T) -> InputBuilder<'a, E, Set<label>>
where T: Into<Plain>,

Set label (Required)

A label that appears above an input element in the form of a text object 🔗 that must have type of plain_text.

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

Source

pub fn block_id<S>(self, block_id: S) -> Self
where S: Into<Cow<'a, str>>,

Set block_id (Optional)

A string acting as a unique identifier for a block.

You can use this block_id when you receive an interaction payload to identify the source of the action 🔗.

If not specified, a block_id will be generated.

Maximum length for this field is 255 characters.

Source

pub fn dispatch_actions(self, should: bool) -> Self

Set dispatch_action (Optional)

Will allow the elements in this block to dispatch block_actions payloads.

Defaults to false.

Source

pub fn optional(self, optional: bool) -> Self

Sets optional (Required)

A boolean that indicates whether the input element may be empty when a user submits the modal.

Defaults to false.

Source

pub fn hint<T>(self, hint: T) -> Self
where T: Into<Plain>,

Set hint (Optional)

An optional hint that appears below an input element in a lighter grey.

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

Source§

impl<'a, L> InputBuilder<'a, RequiredMethodNotCalled<element>, L>

Source

pub fn element<El>(self, element: El) -> InputBuilder<'a, Set<element>, L>
where El: Into<SupportedElement<'a>>,

Set element (Required)

An interactive block_element that will be used to gather the input for this block.

For the kinds of Elements supported by Input blocks, see the SupportedElement enum.

Source

pub fn child<El>(self, element: El) -> InputBuilder<'a, Set<element>, L>
where El: Into<SupportedElement<'a>>,

Available on crate feature blox only.

XML child alias for element

Source§

impl<'a> InputBuilder<'a, Set<element>, Set<label>>

Source

pub fn build(self) -> Input<'a>

All done building, now give me a darn actions block!

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

use slack_blocks::blocks::Input;

let foo = Input::builder().build(); // Won't compile!
use slack_blocks::{blocks::Input,
                   compose::text::ToSlackPlaintext,
                   elems::TextInput};

let block =
  Input::builder().label("foo".plaintext())
                  .element(TextInput::builder().action_id("foo").build())
                  .build();

Trait Implementations§

Source§

impl<'a, Element: Debug, Label: Debug> Debug for InputBuilder<'a, Element, Label>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, Element, Label> Freeze for InputBuilder<'a, Element, Label>

§

impl<'a, Element, Label> RefUnwindSafe for InputBuilder<'a, Element, Label>
where Element: RefUnwindSafe, Label: RefUnwindSafe,

§

impl<'a, Element, Label> Send for InputBuilder<'a, Element, Label>
where Element: Send, Label: Send,

§

impl<'a, Element, Label> Sync for InputBuilder<'a, Element, Label>
where Element: Sync, Label: Sync,

§

impl<'a, Element, Label> Unpin for InputBuilder<'a, Element, Label>
where Element: Unpin, Label: Unpin,

§

impl<'a, Element, Label> UnwindSafe for InputBuilder<'a, Element, Label>
where Element: UnwindSafe, Label: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoChild for T

Source§

fn into_child(self) -> Self

Available on crate feature blox only.
Identity function
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,