Struct slack_blocks::text::build::TextBuilder[][src]

pub struct TextBuilder<T, TMarker> { /* fields omitted */ }
Expand description

Text Builder

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

Required Methods

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

  • text
  • plain or mrkdwn
use slack_blocks::text::Text;

let foo = Text::builder().plain().text("foo").build();

Implementations

impl<T> TextBuilder<T, RequiredMethodNotCalled<text>>[src]

pub fn new() -> Self[src]

Construct a new text builder

pub fn text(self, t: impl AsRef<str>) -> TextBuilder<T, Set<text>>[src]

Set text (Required)

The text contents to render for this Text object.

For some basic formatting examples, see the docs for the text::Mrkdwn, or Slack’s markdown docs 🔗.

There are no intrinsic length limits on this, those are usually requirements of the context the text will be used in.

pub fn child(self, t: impl AsRef<str>) -> TextBuilder<T, Set<text>>[src]

This is supported on crate feature blox only.

Alias of text for XML macros, allowing text to be set as a string literal instead of an attribute.

use slack_blocks::blox::*;

let as_attr = blox! {
  <text kind=plain text="Foo" />
};

let as_child = blox! {
  <text kind=plain>"Foo"</text>
};

assert_eq!(as_attr, as_child);

impl<M> TextBuilder<Text, M>[src]

pub fn kind<T, K>(self, kind: K) -> TextBuilder<T, M> where
    T: Into<Text>,
    K: TextKind<T>, 
[src]

This is supported on crate feature blox only.

Set the kind of the text you’re building (Required)

Intended to be used as an XML attribute with build::kind::mrkdwn or build::kind::plain

use slack_blocks::{blox::*, text};

let xml = blox! {<text kind=plain>"Foo"</text>};

let builder = text::Plain::from("Foo");

assert_eq!(xml, builder)

pub fn plain(self) -> TextBuilder<Plain, M>[src]

Set the text you’re building to be plain_text (Required)

pub fn mrkdwn(self) -> TextBuilder<Mrkdwn, M>[src]

Set the text you’re building to be mrkdwn (Required)

impl<M> TextBuilder<Mrkdwn, M>[src]

pub fn verbatim(self, verbatim: bool) -> Self[src]

Set verbatim (Optional)

When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed.

Using a value of true will skip any preprocessing of this nature, although you can still include manual parsing strings.

impl<M> TextBuilder<Plain, M>[src]

pub fn emoji(self, emoji: bool) -> Self[src]

Set emoji (Optional)

Indicates whether emojis in a text field should be escaped into the colon emoji format

impl TextBuilder<Plain, Set<text>>[src]

pub fn build(self) -> Plain[src]

All done building, now give me a darn text object!

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

use slack_blocks::text::Text;

let foo = Text::builder().build(); // Won't compile!
use slack_blocks::text::Text;

let foo = Text::builder().plain()
                         .emoji(true)
                         .text("foo :joy:")
                         .build();

impl TextBuilder<Mrkdwn, Set<text>>[src]

pub fn build(self) -> Mrkdwn[src]

All done building, now give me a darn text object!

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

use slack_blocks::text::Text;

let foo = Text::builder().build(); // Won't compile!
use slack_blocks::text::Text;

let foo = Text::builder().mrkdwn()
                         .verbatim(true)
                         .text("foo :joy:")
                         .build();

Trait Implementations

impl<T: Debug, TMarker: Debug> Debug for TextBuilder<T, TMarker>[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T, TMarker> RefUnwindSafe for TextBuilder<T, TMarker> where
    T: RefUnwindSafe,
    TMarker: RefUnwindSafe

impl<T, TMarker> Send for TextBuilder<T, TMarker> where
    T: Send,
    TMarker: Send

impl<T, TMarker> Sync for TextBuilder<T, TMarker> where
    T: Sync,
    TMarker: Sync

impl<T, TMarker> Unpin for TextBuilder<T, TMarker> where
    T: Unpin,
    TMarker: Unpin

impl<T, TMarker> UnwindSafe for TextBuilder<T, TMarker> where
    T: UnwindSafe,
    TMarker: 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> IntoChild for T[src]

fn into_child(self) -> Self[src]

This is supported on crate feature blox only.

Identity function

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.