1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! The type that represents a block.
//!
//! <https://api.slack.com/reference/block-kit/blocks>

pub mod actions;
pub mod context;
pub mod divider;
pub mod file;
pub mod header;
pub mod image;
pub mod input;
pub mod rich_text;
pub mod section;

use crate::{
    ActionsBlock, ContextBlock, DividerBlock, FileBlock, HeaderBlock, ImageBlock, InputBlock,
    RichTextBlock, SectionBlock,
};
use serde::Serialize;

/// A unique identifier for a block.
#[derive(Serialize, Debug, Clone)]
pub struct BlockId(pub String);

/// The external unique ID for the file. in <https://api.slack.com/reference/block-kit/blocks#file_fields>.
#[derive(Serialize, Debug, Clone)]
pub struct ExternalId(pub String);

/// The type that represents a block.
///
/// <https://api.slack.com/reference/block-kit/blocks>
#[derive(Serialize, Debug, Clone)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum Block {
    /// Actions block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#actions>
    Actions(ActionsBlock),

    /// Context block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#context>
    Context(ContextBlock),

    /// Divider block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#divider>
    Divider(DividerBlock),

    /// File block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#file>
    File(FileBlock),

    /// Header block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#header>
    Header(HeaderBlock),

    /// Image block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#image>
    Image(ImageBlock),

    /// Rich text block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#rich_text>
    RichText(RichTextBlock),

    /// Input block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#input>
    Input(InputBlock),

    /// Section block.
    ///
    /// <https://api.slack.com/reference/block-kit/blocks#section>
    Section(SectionBlock),
    // Video(VideoBlock),
}