Struct slack_blocks::compose::Confirm [−][src]
pub struct Confirm { /* fields omitted */ }
Expand description
Confirm Dialog
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]
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]
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
- Aplain_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 thetext
in this field is 300 characters. -
confirm
- Aplain_text
-only text object 🔗 to define the text of the button that confirms the action. Maximum length for thetext
in this field is 30 characters. -
deny
- Aplain_text
-only text object 🔗 to define the text of the button that cancels the action. Maximum length for thetext
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]
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 theconfirm
button. A value ofdanger
will display the button with a red background on desktop, or red text on mobile. A value ofprimary
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 beprimary
.
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]
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 withtitle
longer than 100 chars - If
from_parts
was called withtext
longer than 300 chars - If
from_parts
was called withconfirm
longer than 30 chars - If
from_parts
was called withdeny
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<'de> Deserialize<'de> for Confirm
[src]
impl<'de> Deserialize<'de> for Confirm
[src]fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[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 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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,