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

source

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);
source

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);
source

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);
source

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);
source

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);
source

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);
source

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);
source

pub fn set_author_name<T: Into<String>>(self, name: T) -> Self

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);
source

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);
source

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);
source

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);
source

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);
source

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);

Trait Implementations§

source§

impl Clone for Video

source§

fn clone(&self) -> Video

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Video

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Video

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<Video> for Block

source§

fn from(value: Video) -> Self

Converts to this type from the input type.
source§

impl Serialize for Video

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Video

§

impl Send for Video

§

impl Sync for Video

§

impl Unpin for Video

§

impl UnwindSafe for Video

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.