1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
use serde::{Deserialize, Serialize}; use crate::val_helpr::ValidationResult; use crate::impl_from_contents; pub mod select; pub mod button; pub use button::Contents as Button; /// # Block Elements - interactive components /// [slack api docs 🔗](https://api.slack.com/reference/block-kit/block-elements) /// /// Block elements can be used inside of `section`, `context`, and `actions` [layout blocks 🔗]. /// Inputs can only be used inside of `input` blocks. /// /// Our overview of [app surfaces that support Block Kit 🔗] shows you where those blocks might be relevant. /// /// Finally, our [handling user interactivity guide 🔗] will help you prepare your app to allow /// for the use of the interactive components listed below. /// /// [app surfaces that support Block Kit 🔗]: https://api.slack.com/messaging/composing/layouts /// [handling user interactivity guide 🔗]: https://api.slack.com/interactivity/handling /// [layout blocks 🔗]: https://api.slack.com/reference/block-kit/blocks #[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)] #[serde(tag = "type", rename_all = "snake_case")] pub enum BlockElement { Button(Button), Checkboxes, DatePicker, Image, MultiSelect, OverflowMenu, Select(select::Contents), PlainInput, RadioButtons, } impl BlockElement { pub fn validate(&self) -> ValidationResult { match self { Self::Button(cts) => cts.validate(), rest => todo!("validation not implemented for {:?}", rest) } } } impl_from_contents!(BlockElement, Button, Button);