1mod text;
10
11pub use self::text::Text;
12
13use af_core::prelude::*;
14
15pub fn header<'a>(text: impl Into<Cow<'a, str>>) -> Block<'a> {
17 Block::Header { text: Text::plain(text) }
18}
19
20pub fn section<'a>(text: impl Into<Cow<'a, str>>) -> Block<'a> {
22 Block::Section { text: Text::mrkdwn(text) }
23}
24
25#[derive(Debug, Serialize)]
27#[serde(rename_all = "snake_case", tag = "type")]
28pub enum Block<'a> {
29 Header { text: Text<'a> },
30 Section { text: Text<'a> },
31}
32
33impl<'a, T> From<T> for Block<'a>
34where
35 Cow<'a, str>: From<T>,
36{
37 fn from(value: T) -> Self {
38 section(value)
39 }
40}