use serde::Serialize;
pub mod builders;
pub mod elements;
pub mod rich_text;
pub mod table;
mod actions;
mod context;
mod context_actions;
mod divider;
mod file;
mod header;
mod image;
mod input;
mod markdown;
mod section;
mod task_card;
mod video;
pub use actions::{Actions, ActionsElement};
pub use context::{Context, ContextElement};
pub use context_actions::{ContextActions, ContextActionsElement};
pub use divider::Divider;
pub use file::{File, FileSource};
pub use header::Header;
pub use image::Image;
pub use input::{Input, InputElement};
pub use markdown::Markdown;
pub use rich_text::RichText;
pub use section::{Accessory, Section};
pub use table::Table;
pub use task_card::{TaskCard, TaskStatus};
pub use video::Video;
#[derive(Debug, Clone, Serialize, PartialEq)]
#[serde(untagged)]
pub enum Block {
Actions(Box<Actions>),
Context(Box<Context>),
ContextActions(Box<ContextActions>),
Divider(Box<Divider>),
File(Box<File>),
Header(Box<Header>),
Image(Box<Image>),
Input(Box<Input>),
Markdown(Box<Markdown>),
RichText(Box<RichText>),
Section(Box<Section>),
Table(Box<Table>),
Video(Box<Video>),
}
macro_rules! block_from {
($($ty:ident,)*) => {
$(
impl From<$ty> for Block {
fn from(value: $ty) -> Self {
Self::$ty(Box::new(value))
}
}
)*
}
}
block_from! {
Actions,
Context,
ContextActions,
Divider,
File,
Header,
Image,
Input,
Markdown,
RichText,
Section,
Table,
Video,
}
#[cfg(test)]
pub mod test_helpers {
use super::rich_text::test_helpers as rich_text_helper;
use super::rich_text::types::test_helpers::*;
use super::*;
use crate::composition_objects::test_helpers::*;
pub fn header(text: impl Into<String>) -> Header {
Header {
block_id: None,
text: Some(plain_text(text)),
}
}
pub fn section(text: impl Into<String>) -> Section {
Section {
block_id: None,
text: Some(mrkdwn_text(text).into()),
fields: None,
accessory: None,
expand: None,
}
}
pub fn rich_text() -> RichText {
RichText {
block_id: Some("rich_text_0".into()),
elements: Some(vec![rich_text_helper::section(vec![el_text("foo")]).into()]),
}
}
}