Struct slack_messaging::blocks::elements::OverflowMenu
source · pub struct OverflowMenu { /* private fields */ }Expand description
Overflow menu element representation.
Example
use slack_messaging::blocks::elements::{OverflowMenu, Opt};
use serde_json::json;
let overflow = OverflowMenu::new()
.set_action_id("overflow_0")
.push_option(
Opt::plain("option-0").set_value("value-0")
)
.push_option(
Opt::plain("option-1").set_value("value-1")
);
let expected = json!({
"type": "overflow",
"action_id": "overflow_0",
"options": [
{
"text": {
"type": "plain_text",
"text": "option-0",
"emoji": true
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "option-1",
"emoji": true
},
"value": "value-1"
}
]
});
let overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);Implementations§
source§impl OverflowMenu
impl OverflowMenu
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Overflow menu element with empty values.
use slack_messaging::blocks::elements::OverflowMenu;
use serde_json::json;
let overflow = OverflowMenu::new();
let expected = json!({
"type": "overflow",
"action_id": ""
});
let overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);sourcepub fn set_action_id<T: Into<String>>(self, action_id: T) -> Self
pub fn set_action_id<T: Into<String>>(self, action_id: T) -> Self
Sets action_id field.
use slack_messaging::blocks::elements::OverflowMenu;
use serde_json::json;
let overflow = OverflowMenu::new().set_action_id("overflow_0");
let expected = json!({
"type": "overflow",
"action_id": "overflow_0"
});
let overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);sourcepub fn set_options(self, options: Vec<Opt>) -> Self
pub fn set_options(self, options: Vec<Opt>) -> Self
Sets options field directly.
use slack_messaging::blocks::elements::{OverflowMenu, Opt};
use serde_json::json;
let overflow = OverflowMenu::new()
.set_options(
vec![
Opt::plain("option-0").set_value("value-0"),
Opt::plain("option-1").set_value("value-1")
]
);
let expected = json!({
"type": "overflow",
"action_id": "",
"options": [
{
"text": {
"type": "plain_text",
"text": "option-0",
"emoji": true
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "option-1",
"emoji": true
},
"value": "value-1"
}
]
});
let overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);sourcepub fn push_option(self, option: Opt) -> Self
pub fn push_option(self, option: Opt) -> Self
Adds Opt object to options field.
use slack_messaging::blocks::elements::{OverflowMenu, Opt};
use serde_json::json;
let overflow = OverflowMenu::new()
.push_option(Opt::plain("option-0").set_value("value-0"));
let expected = json!({
"type": "overflow",
"action_id": "",
"options": [
{
"text": {
"type": "plain_text",
"text": "option-0",
"emoji": true
},
"value": "value-0"
}
]
});
let overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);sourcepub fn set_confirm(self, confirm: ConfirmationDialog) -> Self
pub fn set_confirm(self, confirm: ConfirmationDialog) -> Self
Sets confirm field with ConfirmationDialog object.
use slack_messaging::blocks::elements::{OverflowMenu, ConfirmationDialog};
use serde_json::json;
let overflow = OverflowMenu::new()
.set_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!({
"type": "overflow",
"action_id": "",
"confirm": {
"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 overflow_json = serde_json::to_value(overflow).unwrap();
assert_eq!(overflow_json, expected);Trait Implementations§
source§impl Clone for OverflowMenu
impl Clone for OverflowMenu
source§fn clone(&self) -> OverflowMenu
fn clone(&self) -> OverflowMenu
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 moresource§impl Debug for OverflowMenu
impl Debug for OverflowMenu
source§impl Default for OverflowMenu
impl Default for OverflowMenu
source§impl From<OverflowMenu> for Accessory
impl From<OverflowMenu> for Accessory
source§fn from(value: OverflowMenu) -> Self
fn from(value: OverflowMenu) -> Self
Converts to this type from the input type.
source§impl From<OverflowMenu> for ActionsElement
impl From<OverflowMenu> for ActionsElement
source§fn from(value: OverflowMenu) -> Self
fn from(value: OverflowMenu) -> Self
Converts to this type from the input type.