Struct slack_messaging::blocks::elements::ConfirmationDialog
source · pub struct ConfirmationDialog { /* private fields */ }Expand description
Confirmation dialog object representation.
Example
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::json;
let confirm = ConfirmationDialog::new()
.set_title("Are you sure?")
.set_text("Wouldn't you prefer a good game of _chess_?")
.set_confirm("Do it")
.set_deny("Stop, I've changed my mind!");
let expected = json!({
"title": {
"type": "plain_text",
"text": "Are you sure?",
"emoji": true
},
"text": {
"type": "plain_text",
"text": "Wouldn't you prefer a good game of _chess_?",
"emoji": true
},
"confirm": {
"type": "plain_text",
"text": "Do it",
"emoji": true
},
"deny": {
"type": "plain_text",
"text": "Stop, I've changed my mind!",
"emoji": true
}
});
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json, expected);Implementations§
source§impl ConfirmationDialog
impl ConfirmationDialog
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Confirmation dialog object with empty values.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new();
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["title"]["text"], Value::String("".into()));
assert_eq!(confirm_json["text"]["text"], Value::String("".into()));
assert_eq!(confirm_json["confirm"]["text"], Value::String("".into()));
assert_eq!(confirm_json["deny"]["text"], Value::String("".into()));
assert_eq!(confirm_json["style"], Value::Null);sourcepub fn set_title<T: Into<String>>(self, title: T) -> Self
pub fn set_title<T: Into<String>>(self, title: T) -> Self
Sets title field with plain_text object.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new()
.set_title("Are you sure?");
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["title"]["text"], Value::String("Are you sure?".into()));sourcepub fn set_text<T: Into<String>>(self, text: T) -> Self
pub fn set_text<T: Into<String>>(self, text: T) -> Self
Sets text field with plain_text object.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new()
.set_text("Wouldn't you prefer a good game of _chess_?");
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["text"]["text"], Value::String("Wouldn't you prefer a good game of _chess_?".into()));sourcepub fn set_confirm<T: Into<String>>(self, confirm: T) -> Self
pub fn set_confirm<T: Into<String>>(self, confirm: T) -> Self
Sets confirm field with plain_text object.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new()
.set_confirm("Do it");
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["confirm"]["text"], Value::String("Do it".into()));sourcepub fn set_deny<T: Into<String>>(self, deny: T) -> Self
pub fn set_deny<T: Into<String>>(self, deny: T) -> Self
Sets deny field with plain_text object.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new()
.set_deny("Stop, I've changed my mind!");
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["deny"]["text"], Value::String("Stop, I've changed my mind!".into()));sourcepub fn set_primary(self) -> Self
pub fn set_primary(self) -> Self
Sets style field as “primary”.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new().set_primary();
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["style"], Value::String("primary".into()));sourcepub fn set_danger(self) -> Self
pub fn set_danger(self) -> Self
Sets style field as “danger”.
use slack_messaging::blocks::elements::ConfirmationDialog;
use serde_json::{json, Value};
let confirm = ConfirmationDialog::new().set_danger();
let confirm_json = serde_json::to_value(confirm).unwrap();
assert_eq!(confirm_json["style"], Value::String("danger".into()));Trait Implementations§
source§impl Clone for ConfirmationDialog
impl Clone for ConfirmationDialog
source§fn clone(&self) -> ConfirmationDialog
fn clone(&self) -> ConfirmationDialog
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more