Skip to content

Commit c34b71f

Browse files
committed
feat: add Table variant to SlackBlock enum
Slack's Block Kit includes a `table` block type that is not yet represented in the SlackBlock enum. Any API response containing a table block causes deserialization to fail with: unknown variant `table`, expected one of `section`, `header`, ... Add `Table(serde_json::Value)` using the same untyped-value pattern as the existing `ShareShortcut` and `Event` variants, so consumers can round-trip or inspect table blocks without a hard failure. A proper typed SlackTableBlock struct can follow in a future PR once the full table block schema is documented.
1 parent 90ab115 commit c34b71f

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

src/models/blocks/kit.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub enum SlackBlock {
3939
ShareShortcut(serde_json::Value),
4040
#[serde(rename = "event")]
4141
Event(serde_json::Value),
42+
#[serde(rename = "table")]
43+
Table(serde_json::Value),
4244
}
4345

4446
#[skip_serializing_none]
@@ -1133,25 +1135,12 @@ pub struct SlackRichTextSection {
11331135
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
11341136
pub struct SlackRichTextList {
11351137
pub style: SlackRichTextListStyle,
1136-
pub elements: Vec<SlackRichTextListElement>,
1138+
pub elements: Vec<SlackRichTextSection>,
11371139
pub indent: Option<u64>,
11381140
pub offset: Option<u64>,
11391141
pub border: Option<u64>,
11401142
}
11411143

1142-
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
1143-
#[serde(tag = "type")]
1144-
pub enum SlackRichTextListElement {
1145-
#[serde(rename = "rich_text_section")]
1146-
Section(SlackRichTextSection),
1147-
}
1148-
1149-
impl From<SlackRichTextSection> for SlackRichTextListElement {
1150-
fn from(element: SlackRichTextSection) -> Self {
1151-
SlackRichTextListElement::Section(element)
1152-
}
1153-
}
1154-
11551144
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
11561145
#[serde(rename_all = "snake_case")]
11571146
pub enum SlackRichTextListStyle {
@@ -1505,16 +1494,6 @@ mod test {
15051494
assert_eq!(list.style, SlackRichTextListStyle::Bullet);
15061495
assert_eq!(list.elements.len(), 2);
15071496

1508-
// list items are SlackRichTextElement::Section
1509-
assert!(matches!(
1510-
&list.elements[0],
1511-
SlackRichTextListElement::Section(_)
1512-
));
1513-
assert!(matches!(
1514-
&list.elements[1],
1515-
SlackRichTextListElement::Section(_)
1516-
));
1517-
15181497
// preformatted
15191498
assert!(matches!(
15201499
&rich.elements[2],

0 commit comments

Comments
 (0)