Struct slack_blocks::blocks::context::build::ContextBuilder[][src]

pub struct ContextBuilder<'a, Elements> { /* fields omitted */ }
Expand description

Build an Context block

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

Required Methods

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

  • element

Example

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

let block = Context::builder().element("foo".plaintext())
                              .element(Image::builder().image_url("foo.png")
                                                       .alt_text("pic of foo")
                                                       .build())
                              .build();

Implementations

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

pub fn new() -> Self[src]

Create a new ContextBuilder

pub fn element<El>(self, element: El) -> ContextBuilder<'a, Set<elements>> where
    El: Into<ImageOrText<'a>>, 
[src]

Add an element (Required, can be called many times)

A composition object; Must be image elements or text objects.

Maximum number of items is 10.

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> ContextBuilder<'a, Set<elements>>[src]

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

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

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

use slack_blocks::blocks::Context;

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

let block = Context::builder().element("foo".plaintext())
                              .element(Image::builder().image_url("foo.png")
                                                       .alt_text("pic of foo")
                                                       .build())
                              .build();

Trait Implementations

impl<'a, Elements: Debug> Debug for ContextBuilder<'a, Elements>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, Elements> RefUnwindSafe for ContextBuilder<'a, Elements> where
    Elements: RefUnwindSafe

impl<'a, Elements> Send for ContextBuilder<'a, Elements> where
    Elements: Send

impl<'a, Elements> Sync for ContextBuilder<'a, Elements> where
    Elements: Sync

impl<'a, Elements> Unpin for ContextBuilder<'a, Elements> where
    Elements: Unpin

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