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
//! Image block.
//!
//! <https://api.slack.com/reference/block-kit/blocks#image>

use crate::BlockId;
use crate::TextObject;
use serde::Serialize;

/// Image block.
///
/// <https://api.slack.com/reference/block-kit/blocks#image>
#[derive(Serialize, Debug, Clone)]
#[serde(rename_all = "snake_case")]
pub struct ImageBlock {
    /// A plain-text summary of the image.
    pub alt_text: String,

    /// The URL for a publicly hosted image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_url: Option<url::Url>,

    // /// Slack file object.
    // ///
    // /// <https://api.slack.com/reference/block-kit/composition-objects#slack_file>
    // #[serde(skip_serializing_if = "Option::is_none")]
    // pub slack_file: Option<>,
    /// An optional title for the image in the form of a [text object](https://api.slack.com/reference/messaging/composition-objects#text) that can only be of `type: plain_text`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<TextObject>,

    /// A unique identifier for a block.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub block_id: Option<BlockId>,
}