Struct slack_messaging::blocks::Video
source · pub struct Video { /* private fields */ }Expand description
Video block representation.
Example
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.title("How to use Slack.")
.description("Slack is a new way to communicate with your team. It's faster, better organized and more secure than email.")
.set_title_url("https://www.youtube.com/watch?v=RRxQQxiM7AA")
.set_video_url("https://www.youtube.com/embed/RRxQQxiM7AA?feature=oembed&autoplay=1")
.set_thumbnail_url("https://i.ytimg.com/vi/RRxQQxiM7AA/hqdefault.jpg")
.set_alt_text("How to use Slack?")
.set_author_name("Arcado Buendia")
.set_provider_name("YouTube")
.set_provider_icon_url("https://a.slack-edge.com/80588/img/unfurl_icons/youtube.png");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "How to use Slack.",
"emoji": true
},
"description": {
"type": "plain_text",
"text": "Slack is a new way to communicate with your team. It's faster, better organized and more secure than email.",
"emoji": true
},
"title_url": "https://www.youtube.com/watch?v=RRxQQxiM7AA",
"video_url": "https://www.youtube.com/embed/RRxQQxiM7AA?feature=oembed&autoplay=1",
"thumbnail_url": "https://i.ytimg.com/vi/RRxQQxiM7AA/hqdefault.jpg",
"alt_text": "How to use Slack?",
"author_name": "Arcado Buendia",
"provider_name": "YouTube",
"provider_icon_url": "https://a.slack-edge.com/80588/img/unfurl_icons/youtube.png"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);Implementations§
source§impl Video
impl Video
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Video block.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new();
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_alt_text<T: Into<String>>(self, alt: T) -> Self
pub fn set_alt_text<T: Into<String>>(self, alt: T) -> Self
Sets alt_text field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new().set_alt_text("How to use Slack?");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "How to use Slack?"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_title(self, title: Text) -> Self
pub fn set_title(self, title: Text) -> Self
Sets title field.
use slack_messaging::blocks::Video;
use slack_messaging::blocks::elements::Text;
use serde_json::json;
let video = Video::new()
.set_title(Text::plain("How to use Slack."));
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "How to use Slack.",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn title<T: Into<String>>(self, title: T) -> Self
pub fn title<T: Into<String>>(self, title: T) -> Self
Sets title field from string. This is a shorthand for set_title method.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new().title("How to use Slack.");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "How to use Slack.",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_title_url<T: Into<String>>(self, title_url: T) -> Self
pub fn set_title_url<T: Into<String>>(self, title_url: T) -> Self
Sets title_url field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_title_url("https://www.youtube.com/watch?v=RRxQQxiM7AA");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "",
"title_url": "https://www.youtube.com/watch?v=RRxQQxiM7AA"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_thumbnail_url<T: Into<String>>(self, thumbnail_url: T) -> Self
pub fn set_thumbnail_url<T: Into<String>>(self, thumbnail_url: T) -> Self
Sets thumbnail_url field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_thumbnail_url("https://i.ytimg.com/vi/RRxQQxiM7AA/hqdefault.jpg");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "https://i.ytimg.com/vi/RRxQQxiM7AA/hqdefault.jpg",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_video_url<T: Into<String>>(self, video_url: T) -> Self
pub fn set_video_url<T: Into<String>>(self, video_url: T) -> Self
Sets video_url field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_video_url("https://www.youtube.com/embed/RRxQQxiM7AA?feature=oembed&autoplay=1");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "https://www.youtube.com/embed/RRxQQxiM7AA?feature=oembed&autoplay=1",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);Sets author_name field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_author_name("Arcado Buendia");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "",
"author_name": "Arcado Buendia"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_block_id<T: Into<String>>(self, block_id: T) -> Self
pub fn set_block_id<T: Into<String>>(self, block_id: T) -> Self
Sets block_id field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_block_id("slack video");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "",
"block_id": "slack video"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_description(self, description: Text) -> Self
pub fn set_description(self, description: Text) -> Self
Sets description field.
use slack_messaging::blocks::Video;
use slack_messaging::blocks::elements::Text;
use serde_json::json;
let video = Video::new()
.set_description(Text::plain("Slack is a new way to communicate with your team. It's faster, better organized and more secure than email."));
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"description": {
"type": "plain_text",
"text": "Slack is a new way to communicate with your team. It's faster, better organized and more secure than email.",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn description<T: Into<String>>(self, description: T) -> Self
pub fn description<T: Into<String>>(self, description: T) -> Self
Sets description field from string. This is a shorthand for set_description method.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.description("Slack is a new way to communicate with your team. It's faster, better organized and more secure than email.");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"description": {
"type": "plain_text",
"text": "Slack is a new way to communicate with your team. It's faster, better organized and more secure than email.",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": ""
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_provider_icon_url<T: Into<String>>(self, url: T) -> Self
pub fn set_provider_icon_url<T: Into<String>>(self, url: T) -> Self
Sets provider_icon_url field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_provider_icon_url("https://a.slack-edge.com/80588/img/unfurl_icons/youtube.png");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "",
"provider_icon_url": "https://a.slack-edge.com/80588/img/unfurl_icons/youtube.png"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);sourcepub fn set_provider_name<T: Into<String>>(self, name: T) -> Self
pub fn set_provider_name<T: Into<String>>(self, name: T) -> Self
Sets provider_name field.
use slack_messaging::blocks::Video;
use serde_json::json;
let video = Video::new()
.set_provider_name("YouTube");
let expected = json!({
"type": "video",
"title": {
"type": "plain_text",
"text": "",
"emoji": true
},
"video_url": "",
"thumbnail_url": "",
"alt_text": "",
"provider_name": "YouTube"
});
let video_json = serde_json::to_value(video).unwrap();
assert_eq!(video_json, expected);