mod text;
pub use self::text::Text;
use af_core::prelude::*;
pub fn header<'a>(text: impl Into<Cow<'a, str>>) -> Block<'a> {
Block::Header { text: Text::plain(text) }
}
pub fn section<'a>(text: impl Into<Cow<'a, str>>) -> Block<'a> {
Block::Section { text: Text::mrkdwn(text) }
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "snake_case", tag = "type")]
pub enum Block<'a> {
Header { text: Text<'a> },
Section { text: Text<'a> },
}
impl<'a, T> From<T> for Block<'a>
where
Cow<'a, str>: From<T>,
{
fn from(value: T) -> Self {
section(value)
}
}