TextBuilder

Struct TextBuilder 

Source
pub struct TextBuilder<T, TMarker> { /* private fields */ }
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§

Source§

impl<T> TextBuilder<T, RequiredMethodNotCalled<text>>

Source

pub fn new() -> Self

Construct a new text builder

Source

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

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.

Source

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

Available 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);
Source§

impl<M> TextBuilder<Text, M>

Source

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

Available 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)
Source

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

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

Source

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

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

Source§

impl<M> TextBuilder<Mrkdwn, M>

Source

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

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.

Source§

impl<M> TextBuilder<Plain, M>

Source

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

Set emoji (Optional)

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

Source§

impl TextBuilder<Plain, Set<text>>

Source

pub fn build(self) -> Plain

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();
Source§

impl TextBuilder<Mrkdwn, Set<text>>

Source

pub fn build(self) -> Mrkdwn

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§

Source§

impl<T: Debug, TMarker: Debug> Debug for TextBuilder<T, TMarker>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, TMarker> Freeze for TextBuilder<T, TMarker>

§

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§

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,