[−][src]Struct slack_blocks::compose::opt_group::OptGroup
Option Group
Provides a way to group options in a select menu 🔗 or multi-select menu 🔗.
Implementations
impl OptGroup<()>[src]
pub fn from_label_and_opts<M>(
label: impl Into<Plain>,
options: impl IntoIterator<Item = Opt<M>>
) -> OptGroup<M>[src]
label: impl Into<Plain>,
options: impl IntoIterator<Item = Opt<M>>
) -> OptGroup<M>
Construct an Option Group from a label and collection of options in the group
Arguments
label- Aplain_textonly text object 🔗 that defines the label shown above this group of options. Maximum length for thetextin this field is 75 characters.opts- An array of option objects 🔗 that belong to this specific group. Maximum of 100 items.
Example
use slack_blocks::blocks::Block; use slack_blocks::blocks::section::Contents as Section; use slack_blocks::blocks::actions::Contents as Actions; use slack_blocks::text::{Mrkdwn}; use slack_blocks::compose::{OptGroup, Opt}; let prompt = "Choose your favorite city from each state!"; let blocks: Vec<Block> = vec![ Section::from_text(Mrkdwn::from(prompt)).into(), // TODO: insert option group once block elements are in place Actions::from_action_elements(vec![]).into(), ]; let groups: Vec<OptGroup<_>> = vec![ OptGroup::from_label_and_opts( "Arizona", vec![ Opt::from_mrkdwn_and_value("Phoenix", "az_phx"), // etc... ] ), OptGroup::from_label_and_opts( "California", vec![ Opt::from_mrkdwn_and_value("San Diego", "ca_sd"), // etc... ] ), ];
impl<M> OptGroup<M>[src]
pub fn validate(&self) -> Result<(), ValidationErrors>[src]
Validate that this Option Group object agrees with Slack's model requirements
Errors
- If
from_label_and_optswas called withlabellonger than 75 chars - If
from_label_and_optswas called with more than 100 options
Example
use slack_blocks::compose::{OptGroup, Opt}; use std::iter::repeat; let long_string: String = repeat(' ').take(76).collect(); let opt = Opt::from_mrkdwn_and_value("San Diego", "ca_sd"); let grp = OptGroup::from_label_and_opts(long_string, vec![opt]); assert_eq!(true, matches!(grp.validate(), Err(_)));
Trait Implementations
impl<M: Clone> Clone for OptGroup<M>[src]
impl<M: Debug> Debug for OptGroup<M>[src]
impl<'de, M> Deserialize<'de> for OptGroup<M> where
M: Deserialize<'de>, [src]
M: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl<M: Hash> Hash for OptGroup<M>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<M: PartialEq> PartialEq<OptGroup<M>> for OptGroup<M>[src]
impl<M> Serialize for OptGroup<M> where
M: Serialize, [src]
M: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl<M> StructuralPartialEq for OptGroup<M>[src]
impl<M> Validate for OptGroup<M>[src]
fn validate(&self) -> Result<(), ValidationErrors>[src]
Auto Trait Implementations
impl<M> RefUnwindSafe for OptGroup<M> where
M: RefUnwindSafe,
M: RefUnwindSafe,
impl<M> Send for OptGroup<M> where
M: Send,
M: Send,
impl<M> Sync for OptGroup<M> where
M: Sync,
M: Sync,
impl<M> Unpin for OptGroup<M> where
M: Unpin,
M: Unpin,
impl<M> UnwindSafe for OptGroup<M> where
M: UnwindSafe,
M: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,