sfr_types/layout.rs
1//! The type that represents a composition object.
2//!
3//! <https://api.slack.com/reference/surfaces/formatting#rich-layouts>
4
5use crate::Block;
6use serde::Serialize;
7
8/// The type that represents a composition object.
9///
10/// <https://api.slack.com/reference/surfaces/formatting#rich-layouts>
11#[derive(Serialize, Debug, Clone)]
12#[serde(untagged)]
13pub enum Layouts {
14 /// Defining a single block.
15 ///
16 /// <https://api.slack.com/reference/surfaces/formatting#define_block>
17 SingleBlock(Box<Block>),
18
19 /// Stacking multiple blocks.
20 ///
21 /// <https://api.slack.com/reference/surfaces/formatting#stack_of_blocks>
22 MultipleBlocks(Vec<Block>),
23
24 /// Adding your blocks array.
25 ///
26 /// <https://api.slack.com/reference/surfaces/formatting#add_blocks_array>
27 BlocksArray(MessagePayloads),
28}
29
30/// Message payloads.
31///
32/// <https://api.slack.com/surfaces/messages#payloads>
33#[derive(Serialize, Debug, Clone)]
34#[serde(rename_all = "snake_case")]
35pub struct MessagePayloads {
36 /// The usage of this field changes depending on whether you're using `blocks` or not.
37 pub text: String,
38
39 /// An array of [layout blocks](https://api.slack.com/reference/block-kit/blocks) in the same format [as described in the building blocks guide](https://api.slack.com/block-kit/building).
40 #[serde(skip_serializing_if = "Vec::is_empty")]
41 pub blocks: Vec<Block>,
42
43 /// An array of [legacy secondary attachments](https://api.slack.com/reference/messaging/attachments).
44 #[serde(skip_serializing_if = "Vec::is_empty")]
45 pub attachments: Vec<String>,
46
47 /// The [ID of another un-threaded message](https://api.slack.com/surfaces/messages#threading) to reply to.
48 #[serde(skip_serializing_if = "Option::is_none")]
49 pub thread_ts: Option<String>,
50
51 /// Determines whether the text field is rendered according to [`mrkdwn` formatting or not](https://api.slack.com/reference/surfaces/formatting#basics).
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub mrkdwn: Option<bool>,
54}