Struct slack_blocks::elems::image::build::ImageBuilder[][src]

pub struct ImageBuilder<'a, U, A> { /* fields omitted */ }
Expand description

Image Element builder

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

Required Methods

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

  • image_url
  • alt_text

Example

use slack_blocks::{blocks::{Block, Context},
                   elems::Image};

let img = Image::builder().image_url("foo").alt_text("bar").build();

let block: Block =
  Context::from_context_elements(std::iter::once(img)).into();

// <send block to slack API>

Implementations

impl<'a, U, A> ImageBuilder<'a, U, A>[src]

pub fn new() -> Self[src]

Construct a new builder

pub fn image_url<S>(self, image_url: S) -> ImageBuilder<'a, Set<image_url>, A> where
    S: Into<Cow<'a, str>>, 
[src]

Set image_url (Required)

The URL of the image to be displayed.

pub fn alt_text<S>(self, alt_text: S) -> ImageBuilder<'a, U, Set<alt_text>> where
    S: Into<Cow<'a, str>>, 
[src]

Set alt_text (Required)

A plain-text summary of the image.

This should not contain any markup.

impl<'a> ImageBuilder<'a, Set<image_url>, Set<alt_text>>[src]

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

All done building, now give me a darn image element!

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

use slack_blocks::elems::Image;

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

let foo = Image::builder().image_url("https://foo.com/bar.png")
                          .alt_text("pic of bar")
                          .build();

Trait Implementations

impl<'a, U: Debug, A: Debug> Debug for ImageBuilder<'a, U, A>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a, U, A> RefUnwindSafe for ImageBuilder<'a, U, A> where
    A: RefUnwindSafe,
    U: RefUnwindSafe

impl<'a, U, A> Send for ImageBuilder<'a, U, A> where
    A: Send,
    U: Send

impl<'a, U, A> Sync for ImageBuilder<'a, U, A> where
    A: Sync,
    U: Sync

impl<'a, U, A> Unpin for ImageBuilder<'a, U, A> where
    A: Unpin,
    U: Unpin

impl<'a, U, A> UnwindSafe for ImageBuilder<'a, U, A> where
    A: UnwindSafe,
    U: 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.