pub struct Radio<'a> { /* private fields */ }Expand description
§Radio Buttons
A radio button group that allows a user to choose one item from a list of possible options.
Works in blocks 🔗: Section, Actions, Input Works in app surfaces 🔗: Home tabs, Modals, Messages
Implementations§
Source§impl<'a> Radio<'a>
impl<'a> Radio<'a>
Sourcepub fn builder() -> RadioBuilderInit<'a>
pub fn builder() -> RadioBuilderInit<'a>
Sourcepub fn validate(&self) -> Result<(), ValidationErrors>
Available on crate feature validation only.
pub fn validate(&self) -> Result<(), ValidationErrors>
validation only.Validate that this select element agrees with Slack’s model requirements
§Errors
- length of
action_idgreater than 255 - length of
optionsgreater than 10 - one or more of
optionsis invalid initial_optionis set and an invalidOptconfirmis set and an invalidConfirm
§Example
use slack_blocks::{compose::Opt, elems::Radio};
fn repeat<T: Copy>(el: T, n: usize) -> impl Iterator<Item = T> {
std::iter::repeat(el).take(n)
}
let long_string: String = repeat('a', 256).collect();
let opt = Opt::builder().text_md("foo").value("bar").build();
let opts = repeat(&opt, 11).map(|o| o.clone()).collect::<Vec<_>>();
let input = Radio::builder().action_id(long_string)
.options(opts)
.build();
assert!(matches!(input.validate(), Err(_)))Trait Implementations§
Source§impl<'de, 'a> Deserialize<'de> for Radio<'a>
impl<'de, 'a> Deserialize<'de> for Radio<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> From<Radio<'a>> for BlockElement<'a>
impl<'a> From<Radio<'a>> for BlockElement<'a>
Source§impl<'a> From<Radio<'a>> for SupportedElement<'a>
impl<'a> From<Radio<'a>> for SupportedElement<'a>
Source§impl<'a> From<Radio<'a>> for SupportedElement<'a>
impl<'a> From<Radio<'a>> for SupportedElement<'a>
impl<'a> StructuralPartialEq for Radio<'a>
Auto Trait Implementations§
impl<'a> Freeze for Radio<'a>
impl<'a> RefUnwindSafe for Radio<'a>
impl<'a> Send for Radio<'a>
impl<'a> Sync for Radio<'a>
impl<'a> Unpin for Radio<'a>
impl<'a> UnwindSafe for Radio<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more