Struct slack_blocks::compose::opt_group::build::OptGroupBuilder [−][src]
pub struct OptGroupBuilder<'a, T, U, Options, Label> { /* fields omitted */ }
Expand description
Option Group builder
Allows you to construct a Option Group object safely, with compile-time checks on required setter methods.
Required Methods
OptGroup::build()
is only available if these methods have been called:
options
label
Example
use std::convert::TryFrom; use slack_blocks::{elems::{select::Static, BlockElement}, blocks::{Actions, Block}, compose::{Opt, OptGroup}}; #[derive(Clone, Copy, PartialEq)] enum LangStyle { Functional, ObjectOriented, SomewhereInbetween, } use LangStyle::*; #[derive(Clone, Copy)] struct Lang { name: &'static str, code: &'static str, style: LangStyle, } impl Lang { fn new(name: &'static str, code: &'static str, style: LangStyle) -> Self { Self { name, code, style, } } } let langs = vec![ Lang::new("Rust", "rs", SomewhereInbetween), Lang::new("C#", "cs", ObjectOriented), Lang::new("Haskell", "hs", Functional), ]; let langs_of_style = |needle: LangStyle| langs.iter() .filter(|Lang {style, ..}| *style == needle) .map(|lang| Opt::builder() .text_plain(lang.name) .value(lang.code) .build() ) .collect::<Vec<_>>(); let groups = vec![ OptGroup::builder() .label("Functional") .options(langs_of_style(Functional)) .build(), OptGroup::builder() .label("Object-Oriented") .options(langs_of_style(ObjectOriented)) .build(), OptGroup::builder() .label("Somewhere Inbetween") .options(langs_of_style(SomewhereInbetween)) .build(), ]; let select: BlockElement = Static::builder().placeholder("Choose your favorite programming language!") .option_groups(groups) .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<'a, T, U, O, L> OptGroupBuilder<'a, T, U, O, L>
[src]
impl<'a, T, U, O, L> OptGroupBuilder<'a, T, U, O, L>
[src]pub fn options<T2, U2, I>(
self,
options: I
) -> OptGroupBuilder<'a, T2, U2, Set<options>, L> where
I: IntoIterator<Item = Opt<'a, T2, U2>>,
[src]
pub fn options<T2, U2, I>(
self,
options: I
) -> OptGroupBuilder<'a, T2, U2, Set<options>, L> where
I: IntoIterator<Item = Opt<'a, T2, U2>>,
[src]Set the options of this group (Required)
An array of option objects 🔗 that belong to this specific group.
Maximum of 100 items.
pub fn label<S>(self, label: S) -> OptGroupBuilder<'a, T, U, O, Set<label>> where
S: Into<Plain>,
[src]
pub fn label<S>(self, label: S) -> OptGroupBuilder<'a, T, U, O, Set<label>> where
S: Into<Plain>,
[src]A plain_text
only text object 🔗 that defines
the label shown above this group of options.
Maximum length for the text
in this field is 75 characters.
impl<'a, T, U> OptGroupBuilder<'a, T, U, Set<options>, Set<label>>
[src]
impl<'a, T, U> OptGroupBuilder<'a, T, U, Set<options>, Set<label>>
[src]pub fn build(self) -> OptGroup<'a, T, U>
[src]
pub fn build(self) -> OptGroup<'a, T, U>
[src]All done building, now give me a darn option group!
no method name 'build' found for struct 'compose::opt_group::build::OptGroupBuilder<...>'
? Make sure all required setter methods have been called. See docs forOptGroupBuilder
.
ⓘ
use slack_blocks::compose::OptGroup; let sel = OptGroup::builder() .build(); /* ^^^^^ method not found in `OptGroupBuilder<'_, RequiredMethodNotCalled<options>, RequiredMethodNotCalled<value>, _>` */
use slack_blocks::compose::{Opt, OptGroup}; let sel = OptGroup::builder().options(vec![Opt::builder().text_plain("foo") .value("bar") .build()]) .label("foo") .build();
Trait Implementations
Auto Trait Implementations
impl<'a, T, U, Options, Label> RefUnwindSafe for OptGroupBuilder<'a, T, U, Options, Label> where
Label: RefUnwindSafe,
Options: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
Label: RefUnwindSafe,
Options: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<'a, T, U, Options, Label> Send for OptGroupBuilder<'a, T, U, Options, Label> where
Label: Send,
Options: Send,
T: Send,
U: Send,
Label: Send,
Options: Send,
T: Send,
U: Send,
impl<'a, T, U, Options, Label> Sync for OptGroupBuilder<'a, T, U, Options, Label> where
Label: Sync,
Options: Sync,
T: Sync,
U: Sync,
Label: Sync,
Options: Sync,
T: Sync,
U: Sync,
impl<'a, T, U, Options, Label> Unpin for OptGroupBuilder<'a, T, U, Options, Label> where
Label: Unpin,
Options: Unpin,
T: Unpin,
U: Unpin,
Label: Unpin,
Options: Unpin,
T: Unpin,
U: Unpin,
impl<'a, T, U, Options, Label> UnwindSafe for OptGroupBuilder<'a, T, U, Options, Label> where
Label: UnwindSafe,
Options: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
Label: UnwindSafe,
Options: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,