pub struct ConfirmationDialog { /* private fields */ }Expand description
Confirmation dialog object representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| title | Text<Plain> | Yes | Max length 100 characters |
| text | Text<Plain> | Yes | Max length 300 characters |
| confirm | Text<Plain> | Yes | Max length 30 characters |
| deny | Text<Plain> | Yes | Max length 30 characters |
| style | &str | No | Must be either “primary” or “danger” |
§Example
use slack_messaging::plain_text;
use slack_messaging::composition_objects::ConfirmationDialog;
let dialog = ConfirmationDialog::builder()
.title(plain_text!("Are you sure?")?)
.text(plain_text!("Wouldn't you prefer a good game of _chess_?")?)
.confirm(plain_text!("Do it")?)
.deny(plain_text!("Stop, I've changed my mind!")?)
.primary()
.build()?;
let expected = serde_json::json!({
"title": {
"type": "plain_text",
"text": "Are you sure?"
},
"text": {
"type": "plain_text",
"text": "Wouldn't you prefer a good game of _chess_?"
},
"confirm": {
"type": "plain_text",
"text": "Do it"
},
"deny": {
"type": "plain_text",
"text": "Stop, I've changed my mind!"
},
"style": "primary"
});
let json = serde_json::to_value(dialog).unwrap();
assert_eq!(json, expected);
// If your object has any validation errors, the build method returns Result::Err
let dialog = ConfirmationDialog::builder()
.text(plain_text!("Wouldn't you prefer a good game of _chess_?")?)
.confirm(plain_text!("Do it")?)
.deny(plain_text!("Stop, I've changed my mind!")?)
.build();
assert!(dialog.is_err());Implementations§
Source§impl ConfirmationDialog
impl ConfirmationDialog
Sourcepub fn builder() -> ConfirmationDialogBuilder
pub fn builder() -> ConfirmationDialogBuilder
constract ConfirmationDialogBuilder object.
Trait Implementations§
Source§impl Clone for ConfirmationDialog
impl Clone for ConfirmationDialog
Source§fn clone(&self) -> ConfirmationDialog
fn clone(&self) -> ConfirmationDialog
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfirmationDialog
impl Debug for ConfirmationDialog
Source§impl PartialEq for ConfirmationDialog
impl PartialEq for ConfirmationDialog
Source§impl Serialize for ConfirmationDialog
impl Serialize for ConfirmationDialog
impl StructuralPartialEq for ConfirmationDialog
Auto Trait Implementations§
impl Freeze for ConfirmationDialog
impl RefUnwindSafe for ConfirmationDialog
impl Send for ConfirmationDialog
impl Sync for ConfirmationDialog
impl Unpin for ConfirmationDialog
impl UnwindSafe for ConfirmationDialog
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)