Struct slack_blocks::compose::Confirm[][src]

pub struct Confirm { /* fields omitted */ }
Expand description

Confirm Dialog

slack api docs 🔗

An object that defines a dialog that provides a confirmation step to any interactive element. This dialog will ask the user to confirm their action by offering a confirm and deny buttons.

Implementations

impl Confirm[src]

pub fn from_parts(
    title: impl Into<Plain>,
    text: impl Into<Text>,
    confirm: impl Into<Plain>,
    deny: impl Into<Plain>
) -> Self
[src]

Creates a Confirmation Dialog from the required parts.

Arguments

  • title - A plain_text-only text object 🔗 that defines the dialog’s title. Maximum length for this field is 100 characters.

  • text - A text object 🔗 that defines the explanatory text that appears in the confirm dialog. Maximum length for the text in this field is 300 characters.

  • confirm - A plain_text-only text object 🔗 to define the text of the button that confirms the action. Maximum length for the text in this field is 30 characters.

  • deny - A plain_text-only text object 🔗 to define the text of the button that cancels the action. Maximum length for the text in this field is 30 characters.

Example

use slack_blocks::compose::Confirm;
use slack_blocks::text;

let dialog = Confirm::from_parts(
    "Are you sure?",
    text::Mrkdwn::from("Are you _sure_ you're sure?\nThis action is permanent."),
    "I'm sure.",
    "I'm not sure!",
);

// Results in a modal that looks like:
//  _______________________________
// |                               |
// | Are you sure?                 |
// |_______________________________|
// |                               |
// | Are you _sure_ you're sure?   |
// | This action is permanent.     |
// |_______________________________|
// |                               |
// |   |I'm not sure!| |I'm sure.| |
// |_______________________________|

pub fn with_style(self, style: ConfirmStyle) -> Self[src]

Chainable setter method, used to set the style of the confirm button of your modal.

Arguments

  • style - Defines the color scheme applied to the confirm button. A value of danger will display the button with a red background on desktop, or red text on mobile. A value of primary will display the button with a green background on desktop, or blue text on mobile. If this field is not provided, the default value will be primary.

Example

use slack_blocks::compose::{Confirm, ConfirmStyle};
use slack_blocks::text;

let dialog = Confirm::from_parts(
        "Are you sure?",
        text::Mrkdwn::from("Are you _sure_ you're sure?\nThis action is permanent."),
        "I'm sure.",
        "I'm not sure!",
    )
    .with_style(ConfirmStyle::Danger);

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

Validate that this Confirm composition object agrees with Slack’s model requirements

Errors

  • If from_parts was called with title longer than 100 chars
  • If from_parts was called with text longer than 300 chars
  • If from_parts was called with confirm longer than 30 chars
  • If from_parts was called with deny longer than 30 chars

Example

use slack_blocks::compose::{Confirm, ConfirmStyle};
use slack_blocks::text;

let dialog = Confirm::from_parts(
        "Are you sure?",
        text::Mrkdwn::from("Are you _sure_ you're sure?\nThis action is permanent."),
        "I'm sure.",
        "I'm not sure! Oh, geez, I just don't know! Help me decide, please??? Gosh, this is scary...",
    )
    .with_style(ConfirmStyle::Danger);

assert_eq!(true, matches!(dialog.validate(), Err(_)));

Trait Implementations

impl Clone for Confirm[src]

fn clone(&self) -> Confirm[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 Debug for Confirm[src]

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

Formats the value using the given formatter. Read more

impl<'de> Deserialize<'de> for Confirm[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 Hash for Confirm[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 PartialEq<Confirm> for Confirm[src]

fn eq(&self, other: &Confirm) -> bool[src]

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

fn ne(&self, other: &Confirm) -> bool[src]

This method tests for !=.

impl Serialize for Confirm[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 Validate for Confirm[src]

impl StructuralPartialEq for Confirm[src]

Auto Trait Implementations

impl RefUnwindSafe for Confirm

impl Send for Confirm

impl Sync for Confirm

impl Unpin for Confirm

impl UnwindSafe for Confirm

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]