Struct slack_blocks::blocks::section::build::SectionBuilder[][src]

pub struct SectionBuilder<'a, Text> { /* fields omitted */ }
Expand description

Build an Section block

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

Required Methods

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

  • element

Example

use slack_blocks::{blocks::Section, elems::Image, text::ToSlackPlaintext};

let block =
  Section::builder().text("foo".plaintext())
                    .accessory(Image::builder().image_url("foo.png")
                                               .alt_text("pic of foo")
                                               .build())
                    .build();

Implementations

impl<'a, E> SectionBuilder<'a, E>[src]

pub fn new() -> Self[src]

Create a new SectionBuilder

pub fn accessory<B>(self, acc: B) -> Self where
    B: Into<BlockElement<'a>>, 
[src]

Set accessory (Optional)

pub fn text<T>(self, text: T) -> SectionBuilder<'a, Set<text>> where
    T: Into<Text>, 
[src]

Add text (Required, can be called many times)

One or many text objects 🔗 to populate the block with.

If called once:

Sets the text field of the section block.

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

If called multiple times:

Sets the fields field of the section block.

Fields will be rendered in a compact format that allows for 2 columns of side-by-side text. Maximum number of items is 10.

Maximum length for the text in each item is 2000 characters.

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

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.

impl<'a> SectionBuilder<'a, Set<text>>[src]

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

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

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

use slack_blocks::blocks::Section;

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

let block =
  Section::builder().text("foo".plaintext())
                    .accessory(Image::builder().image_url("foo.png")
                                               .alt_text("pic of foo")
                                               .build())
                    .build();

Trait Implementations

impl<'a, Text: Debug> Debug for SectionBuilder<'a, Text>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, Text> RefUnwindSafe for SectionBuilder<'a, Text> where
    Text: RefUnwindSafe

impl<'a, Text> Send for SectionBuilder<'a, Text> where
    Text: Send

impl<'a, Text> Sync for SectionBuilder<'a, Text> where
    Text: Sync

impl<'a, Text> Unpin for SectionBuilder<'a, Text> where
    Text: Unpin

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