war-pigeon 0.1.0

An ergonomic Rust client for War Pigeon, the runtime message delivery system.
Documentation
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

/// An embed for the discord message.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbed {
    /// The title of the embed.
    ///
    /// NOTE: max limit of 256 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,

    /// The description of the embed.
    ///
    /// NOTE: max limit of 4096 characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// The link for the embed title.
    ///
    /// NOTE: Only usable with [`DiscordEmbed::title`].
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,

    /// The timestamp of the embed content.
    ///
    /// NOTE: Display's at bottom of the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timestamp: Option<DateTime<Utc>>,

    /// The color code of the embed.
    ///
    /// NOTE: Thin bar to left of embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub color: Option<i64>,

    /// The footer information of the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub footer: Option<DiscordEmbedFooter>,

    /// An image for the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image: Option<DiscordEmbedImage>,

    /// A thumbnail for the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thumbnail: Option<DiscordEmbedThumbnail>,

    /// A video for the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub video: Option<DiscordEmbedVideo>,

    /// An author for the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub author: Option<DiscordEmbedAuthor>,

    /// An array of fields for the embed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub fields: Option<Vec<DiscordEmbedField>>,
}

/// A thumbnail for the embed.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedThumbnail {
    /// A source url for the video.
    pub url: String,

    /// A proxied url for the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_url: Option<String>,

    /// The height of the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,

    /// The width of the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
}

/// A video for the embed.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedVideo {
    /// A source url for the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,

    /// A proxied url for the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_url: Option<String>,

    /// The height of the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,

    /// The width of the video.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
}

/// An image for the embed.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedImage {
    /// A source url for the image.
    ///
    /// NOTE: Only supports http(s) and attachments.
    pub url: String,

    /// A proxied url for the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_url: Option<String>,

    /// The height of the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,

    /// The width of the image.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
}

/// An author of the embed.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedAuthor {
    /// The name of the author.
    ///
    /// NOTE: max limit of 256 characters.
    pub name: String,

    /// A url to attach to the author name.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,

    /// A url to an icon to set for the author.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub icon_url: Option<String>,

    /// A proxied url to an icon to set for the author.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_icon_url: Option<String>,
}

/// A footer for the embed.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedFooter {
    /// The text of footer.
    ///
    /// NOTE: max limit of 2048 characters.
    pub text: String,

    /// The url of the footer icon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub icon_url: Option<String>,

    /// A proxied url of the footer icon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub proxy_icon_url: Option<String>,
}

/// An Embed field.
///
/// NOTE: max limit of 25 fields.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct DiscordEmbedField {
    /// The name of the field.
    ///
    /// NOTE: max limit of 256 characters.
    pub name: String,

    /// The value of the field.
    ///
    /// NOTE: max limit of 4096 characters.
    pub value: String,

    /// Whether or not this field should display inline?
    ///
    /// NOTE: Defaults to false when None.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub inline: Option<bool>,
}