Struct slack_hook_clux::AttachmentBuilder
source · pub struct AttachmentBuilder { /* private fields */ }
Expand description
AttachmentBuilder
is used to build a Attachment
Implementations§
source§impl AttachmentBuilder
impl AttachmentBuilder
sourcepub fn new<S: Into<SlackText>>(fallback: S) -> AttachmentBuilder
pub fn new<S: Into<SlackText>>(fallback: S) -> AttachmentBuilder
Make a new AttachmentBuilder
Fallback is the only required field which is a plain-text summary of the attachment.
sourcepub fn text<S: Into<SlackText>>(self, text: S) -> AttachmentBuilder
pub fn text<S: Into<SlackText>>(self, text: S) -> AttachmentBuilder
Optional text that appears within the attachment
sourcepub fn color<C: TryInto<HexColor, Err = Error>>(
self,
color: C
) -> AttachmentBuilder
pub fn color<C: TryInto<HexColor, Err = Error>>(
self,
color: C
) -> AttachmentBuilder
Set the color of the attachment
The color can be one of:
String
s:good
,warning
,danger
- The built-in enums:
SlackColor::Good
, etc. - Any valid hex color code: e.g.
#b13d41
or#000
.
hex color codes will be checked to ensure a valid hex number is provided
sourcepub fn pretext<S: Into<SlackText>>(self, pretext: S) -> AttachmentBuilder
pub fn pretext<S: Into<SlackText>>(self, pretext: S) -> AttachmentBuilder
Optional text that appears above the attachment block
sourcepub fn fields(self, fields: Vec<Field>) -> AttachmentBuilder
pub fn fields(self, fields: Vec<Field>) -> AttachmentBuilder
Fields are defined as an array, and hashes contained within it will be displayed in a table inside the message attachment.
Optional small text used to display the author’s name.
Optional URL that will hyperlink the author_name
.
Optional URL that displays a small 16x16px image to the left of the author_name
text.
sourcepub fn title<S: Into<SlackText>>(self, title: S) -> AttachmentBuilder
pub fn title<S: Into<SlackText>>(self, title: S) -> AttachmentBuilder
Optional larger, bolder text above the main body
sourcepub fn title_link<U: TryInto<Url, Err = Error>>(
self,
title_link: U
) -> AttachmentBuilder
pub fn title_link<U: TryInto<Url, Err = Error>>(
self,
title_link: U
) -> AttachmentBuilder
Optional URL to link to from the title
sourcepub fn image_url<U: TryInto<Url, Err = Error>>(
self,
image_url: U
) -> AttachmentBuilder
pub fn image_url<U: TryInto<Url, Err = Error>>(
self,
image_url: U
) -> AttachmentBuilder
Optional URL to an image that will be displayed in the body
sourcepub fn thumb_url<U: TryInto<Url, Err = Error>>(
self,
thumb_url: U
) -> AttachmentBuilder
pub fn thumb_url<U: TryInto<Url, Err = Error>>(
self,
thumb_url: U
) -> AttachmentBuilder
Optional URL to an image that will be displayed as a thumbnail to the right of the body
Optional text that will appear at the bottom of the attachment
Optional URL to an image that will be displayed at the bottom of the attachment
sourcepub fn ts(self, time: &NaiveDateTime) -> AttachmentBuilder
pub fn ts(self, time: &NaiveDateTime) -> AttachmentBuilder
Optional timestamp to be displayed with the attachment
sourcepub fn markdown_in<'a, I: IntoIterator<Item = &'a Section>>(
self,
sections: I
) -> AttachmentBuilder
pub fn markdown_in<'a, I: IntoIterator<Item = &'a Section>>(
self,
sections: I
) -> AttachmentBuilder
Optional sections formatted as markdown.
sourcepub fn build(self) -> Result<Attachment>
pub fn build(self) -> Result<Attachment>
Attempt to build the Attachment