Struct slack_blocks::blocks::Actions[][src]

pub struct Actions<'a> { /* fields omitted */ }
Expand description

Actions Block

slack api docs 🔗

A block that is used to hold interactive elements 🔗

Implementations

impl<'a> Actions<'a>[src]

pub fn builder() -> ActionsBuilderInit<'a>[src]

Build a new Actions block.

For example, see docs for ActionsBuilder.

pub fn new() -> Self[src]

👎 Deprecated since 0.19.1:

use Actions::builder

Create an empty Actions block (shorthand for Default::default())

Example

use slack_blocks::blocks;

let actions: blocks::Block = blocks::Actions::new().into();
// < send block to slack's API >

pub fn with_block_id(self, block_id: impl Into<Cow<'a, str>>) -> Self[src]

👎 Deprecated since 0.19.1:

use Actions::builder

Set the block_id for interactions on an existing Actions

Arguments

  • block_id - A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action 🔗. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.

Example

use slack_blocks::blocks::{Actions, Block};

let actions = Actions::new().with_block_id("tally_ho");
let block: Block = actions.into();
// < send block to slack's API >

pub fn from_elements<Iter>(elements: Iter) -> Result<Self, ()> where
    Iter: IntoIterator<Item = BlockElement<'a>>, 
[src]

👎 Deprecated since 0.19.1:

use Actions::builder

Populate an Actions block with a collection of BlockElements, which may not be supported by Actions blocks.

If you can create a collection of actions::BlockElement, either by creating them directly or invoking BlockElement::into, use from_action_elements.

Arguments

  • elements - An array of interactive element objects 🔗 For a list of BlockElement types that are, see BlockElement. There is a maximum of 5 elements in each action block.

Errors

Errors if the BlockElement is one that is not supported by Actions blocks.

For a list of BlockElement types that are supported, see ::blocks::actions::BlockElement.

Runtime Validation

only validates that the block elements are compatible with Actions, for full runtime model validation see the validate method.

Example

use slack_blocks::{blocks::{Actions, Block},
                   compose,
                   elems};

let btn = elems::Button::from_text_and_action_id("Button", "123");
let actions = Actions::from_elements(vec![btn.into()])?;
let block: Block = actions.into();
// < send block to slack's API >

pub fn from_action_elements<Iter>(elements: Iter) -> Self where
    Iter: IntoIterator<Item = SupportedElement<'a>>, 
[src]

👎 Deprecated since 0.19.1:

use Actions::builder

Populate an Actions block with a collection of BlockElements that are supported by Actions blocks.

This also can be called via the From<Vec<self::SupportedElement>> implementation.

If you have a collection of elements that may not be supported, see from_elements.

Arguments

  • elements - An array of interactive element objects 🔗 For a list of BlockElement types that are supported, see BlockElement. There is a maximum of 5 elements in each action block. Note that if you only ever want 1 item you can choose to pass it Some(element) OR std::iter::once(element) instead of a Vec, bypassing an expensive allocation. Iterator and Option implement IntoIterator 🔗.

Errors

Errors if the BlockElement is one that is not supported by Actions blocks.

Runtime Validation

only validates that the block elements are compatible with Actions, for full runtime model validation see the validate method.

Example

use slack_blocks::{blocks::{Actions, Block},
                   compose,
                   elems};

let btn = elems::Button::from_text_and_action_id("Button", "123");
let actions = Actions::from_action_elements(vec![btn.into()]);
let block: Block = actions.into();

// < send block to slack's API >

pub fn validate(&self) -> Result<(), ValidationErrors>[src]

Validate that this Section block agrees with Slack’s model requirements

Errors

  • If with_block_id was called with a block id longer than 255 chars
  • If from_elements or from_action_elements was called with more than 5 elements.

Example

use slack_blocks::{blocks, compose};

let long_string = std::iter::repeat(' ').take(256).collect::<String>();

let block =
  blocks::Actions::from_action_elements(vec![]).with_block_id(long_string);

assert!(matches!(block.validate(), Err(_)));

Trait Implementations

impl<'a> Clone for Actions<'a>[src]

fn clone(&self) -> Actions<'a>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a> Debug for Actions<'a>[src]

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

Formats the value using the given formatter. Read more

impl<'a> Default for Actions<'a>[src]

fn default() -> Actions<'a>[src]

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

impl<'de, 'a> Deserialize<'de> for Actions<'a>[src]

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<'a> From<Actions<'a>> for Block<'a>[src]

fn from(src: Actions<'a>) -> Self[src]

Performs the conversion.

impl<'a> From<Vec<SupportedElement<'a>, Global>> for Actions<'a>[src]

fn from(src: Vec<SupportedElement<'a>>) -> Self[src]

Performs the conversion.

impl<'a> Hash for Actions<'a>[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<'a> PartialEq<Actions<'a>> for Actions<'a>[src]

fn eq(&self, other: &Actions<'a>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Actions<'a>) -> bool[src]

This method tests for !=.

impl<'a> Serialize for Actions<'a>[src]

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

Serialize this value into the given Serde serializer. Read more

impl<'a> TryFrom<BlockElement<'a>> for Actions<'a>[src]

type Error = ()

The type returned in the event of a conversion error.

fn try_from(element: BlockElement<'a>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<'a> TryFrom<Vec<BlockElement<'a>, Global>> for Actions<'a>[src]

type Error = ()

The type returned in the event of a conversion error.

fn try_from(elements: Vec<BlockElement<'a>>) -> Result<Self, Self::Error>[src]

Performs the conversion.

impl<'a> Validate for Actions<'a>[src]

impl<'a> StructuralPartialEq for Actions<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Actions<'a>

impl<'a> Send for Actions<'a>

impl<'a> Sync for Actions<'a>

impl<'a> Unpin for Actions<'a>

impl<'a> UnwindSafe for Actions<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]