Struct slack_blocks::compose::opt::build::OptBuilder [−][src]
pub struct OptBuilder<'a, Text, Value, Url> { /* fields omitted */ }
Expand description
Option builder
Allows you to construct a Option composition object safely, with compile-time checks on required setter methods.
Required Methods
Opt::build()
is only available if these methods have been called:
text
ortext_plain
ortext_md
value
Example
use std::convert::TryFrom; use slack_blocks::{blocks::{Actions, Block}, compose::Opt, elems::{select::Static, BlockElement}}; let langs = vec![("Rust", "rs"), ("Haskell", "hs"), ("NodeJS", "node")]; let langs = langs.into_iter().map(|(name, code)| { Opt::builder().text_plain(name).value(code).build() }); let select: BlockElement = Static::builder().placeholder("Choose your favorite programming language!") .options(langs) .action_id("lang_chosen") .build() .into(); let block: Block = Actions::try_from(select).expect("actions supports select elements") .into(); // <send block to API>
Implementations
impl<T, V, U> OptBuilder<'static, T, V, U>
[src]
impl<T, V, U> OptBuilder<'static, T, V, U>
[src]pub fn new() -> OptBuilderInit<'static>
[src]
pub fn new() -> OptBuilderInit<'static>
[src]Construct a new OptBuilder
impl<'a, T, V, U> OptBuilder<'a, T, V, U>
[src]
impl<'a, T, V, U> OptBuilder<'a, T, V, U>
[src]pub fn value<S>(self, value: S) -> OptBuilder<'a, T, Set<value>, U> where
S: Into<Cow<'a, str>>,
[src]
pub fn value<S>(self, value: S) -> OptBuilder<'a, T, Set<value>, U> where
S: Into<Cow<'a, str>>,
[src]Set value
(Required)
The string value that will be passed to your app when this option is chosen.
Maximum length for this field is 75 characters.
pub fn desc<S>(self, desc: S) -> OptBuilder<'a, T, V, U> where
S: Into<Plain>,
[src]
pub fn desc<S>(self, desc: S) -> OptBuilder<'a, T, V, U> where
S: Into<Plain>,
[src]Set description
(Optional)
A plain_text
only text object 🔗 that defines
a line of descriptive text shown below the text
field
beside the radio button.
Maximum length for the text
object within this field
is 75 characters.
impl<'a, T, V, U> OptBuilder<'a, RequiredMethodNotCalled<T>, V, U>
[src]
impl<'a, T, V, U> OptBuilder<'a, RequiredMethodNotCalled<T>, V, U>
[src]pub fn text_plain<Txt>(
self,
text: Txt
) -> OptBuilder<'a, Set<(text, Plain)>, V, U> where
Txt: Into<Plain>,
[src]
pub fn text_plain<Txt>(
self,
text: Txt
) -> OptBuilder<'a, Set<(text, Plain)>, V, U> where
Txt: Into<Plain>,
[src]Set text
(Required)
A text object 🔗 that defines the text shown in the option on the menu.
Overflow, select, and multi-select menus
can only use plain_text
objects,
while radio buttons and checkboxes
can use mrkdwn
text objects.
Maximum length for the text
in this field is 75 characters.
pub fn text_md<Txt>(
self,
text: Txt
) -> OptBuilder<'a, Set<(text, Mrkdwn)>, V, U> where
Txt: Into<Mrkdwn>,
[src]
pub fn text_md<Txt>(
self,
text: Txt
) -> OptBuilder<'a, Set<(text, Mrkdwn)>, V, U> where
Txt: Into<Mrkdwn>,
[src]Set text
(Required)
A text object 🔗 that defines the text shown in the option on the menu.
Overflow, select, and multi-select menus
can only use plain_text
objects,
while radio buttons and checkboxes
can use mrkdwn
text objects.
Maximum length for the text
in this field is 75 characters.
pub fn text<Txt>(self, text: Txt) -> OptBuilder<'a, Set<(text, Txt)>, V, U> where
Txt: Into<Text>,
[src]
pub fn text<Txt>(self, text: Txt) -> OptBuilder<'a, Set<(text, Txt)>, V, U> where
Txt: Into<Text>,
[src]Set text
(Required)
A text object 🔗 that defines the text shown in the option on the menu.
Overflow, select, and multi-select menus
can only use plain_text
objects,
while radio buttons and checkboxes
can use mrkdwn
text objects.
Maximum length for the text
in this field is 75 characters.
impl<'a, V, U> OptBuilder<'a, Set<(text, Plain)>, V, U>
[src]
impl<'a, V, U> OptBuilder<'a, Set<(text, Plain)>, V, U>
[src]pub fn url<S>(self, url: S) -> OptBuilder<'a, Set<(text, Plain)>, V, Set<url>> where
S: Into<Cow<'a, str>>,
[src]
pub fn url<S>(self, url: S) -> OptBuilder<'a, Set<(text, Plain)>, V, Set<url>> where
S: Into<Cow<'a, str>>,
[src]Set url
(Optional)
The URL will be loaded in the user’s browser when the option is clicked.
Maximum length for this field is 3000 characters.
The url
attribute is only available in overflow menus 🔗
If you’re using url
, you’ll still receive an interaction payload 🔗
and will need to send an acknowledgement response 🔗.
impl<'a> OptBuilder<'a, Set<(text, Plain)>, Set<value>, Set<url>>
[src]
impl<'a> OptBuilder<'a, Set<(text, Plain)>, Set<value>, Set<url>>
[src]pub fn build(self) -> Opt<'a, Plain, AllowUrl>
[src]
pub fn build(self) -> Opt<'a, Plain, AllowUrl>
[src]All done building, now give me a darn option!
no method name 'build' found for struct 'compose::opt::build::OptBuilder<...>'
?
Make sure all required setter methods have been called. See docs for OptBuilder
.
use slack_blocks::compose::Opt; let sel = Opt::builder().build(); // Won't compile!
use slack_blocks::compose::Opt; let opt = Opt::builder().text_plain("cheese") .value("cheese") .url("https://cheese.com") .build();
impl<'a, T: Into<Text>> OptBuilder<'a, Set<(text, T)>, Set<value>, OptionalMethodNotCalled<url>>
[src]
impl<'a, T: Into<Text>> OptBuilder<'a, Set<(text, T)>, Set<value>, OptionalMethodNotCalled<url>>
[src]pub fn build(self) -> Opt<'a, T, NoUrl>
[src]
pub fn build(self) -> Opt<'a, T, NoUrl>
[src]All done building, now give me a darn option!
no method name 'build' found for struct 'compose::opt::build::OptBuilder<...>'
?
Make sure all required setter methods have been called. See docs for OptBuilder
.
use slack_blocks::compose::Opt; let sel = Opt::builder().text_plain("foo") .build(); /* ^^^^^ method not found in `OptBuilder<'_, Set<(text, text::Plain)>, RequiredMethodNotCalled<value>>` */
use slack_blocks::compose::Opt; let opt = Opt::builder().text_md("cheese").value("cheese").build();
Trait Implementations
Auto Trait Implementations
impl<'a, Text, Value, Url> RefUnwindSafe for OptBuilder<'a, Text, Value, Url> where
Text: RefUnwindSafe,
Url: RefUnwindSafe,
Value: RefUnwindSafe,
Text: RefUnwindSafe,
Url: RefUnwindSafe,
Value: RefUnwindSafe,
impl<'a, Text, Value, Url> Send for OptBuilder<'a, Text, Value, Url> where
Text: Send,
Url: Send,
Value: Send,
Text: Send,
Url: Send,
Value: Send,
impl<'a, Text, Value, Url> Sync for OptBuilder<'a, Text, Value, Url> where
Text: Sync,
Url: Sync,
Value: Sync,
Text: Sync,
Url: Sync,
Value: Sync,
impl<'a, Text, Value, Url> Unpin for OptBuilder<'a, Text, Value, Url> where
Text: Unpin,
Url: Unpin,
Value: Unpin,
Text: Unpin,
Url: Unpin,
Value: Unpin,
impl<'a, Text, Value, Url> UnwindSafe for OptBuilder<'a, Text, Value, Url> where
Text: UnwindSafe,
Url: UnwindSafe,
Value: UnwindSafe,
Text: UnwindSafe,
Url: UnwindSafe,
Value: UnwindSafe,