pub struct SelectMenuStaticOptions { /* private fields */ }Expand description
Select menu of static options representation
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| action_id | String | No | Max length 255 characters |
| options | Vec<Opt> | Conditionally* | Max items 100 |
| option_groups | Vec<OptGroup> | Conditionally* | Max items 100 |
| initial_option | Opt | No | N/A |
| confirm | ConfirmationDialog | No | N/A |
| focus_on_load | bool | No | N/A |
| placeholder | Text<Plain> | No | Max length 150 characters |
§Validation Across Fields
- Either
optionsoroption_groupsis required. Both fields cannot be set simultaneously.
§Example
use slack_messaging::plain_text;
use slack_messaging::blocks::elements::SelectMenuStaticOptions;
use slack_messaging::composition_objects::Opt;
let menu = SelectMenuStaticOptions::builder()
.action_id("text1234")
.option(
Opt::builder()
.text(plain_text!("option-0")?)
.value("value-0")
.build()?
)
.option(
Opt::builder()
.text(plain_text!("option-1")?)
.value("value-1")
.build()?
)
.placeholder(plain_text!("Select an item")?)
.build()?;
let expected = serde_json::json!({
"type": "static_select",
"action_id": "text1234",
"options": [
{
"text": {
"type": "plain_text",
"text": "option-0"
},
"value": "value-0"
},
{
"text": {
"type": "plain_text",
"text": "option-1"
},
"value": "value-1"
}
],
"placeholder": {
"type": "plain_text",
"text": "Select an item"
}
});
let json = serde_json::to_value(menu).unwrap();
assert_eq!(json, expected);
// If your object has any validation errors, the build method returns Result::Err
let menu = SelectMenuStaticOptions::builder()
.action_id("text1234")
.placeholder(plain_text!("Select an item")?)
.build();
assert!(menu.is_err());Implementations§
Source§impl SelectMenuStaticOptions
impl SelectMenuStaticOptions
Sourcepub fn builder() -> SelectMenuStaticOptionsBuilder
pub fn builder() -> SelectMenuStaticOptionsBuilder
constract SelectMenuStaticOptionsBuilder object.
Trait Implementations§
Source§impl Clone for SelectMenuStaticOptions
impl Clone for SelectMenuStaticOptions
Source§fn clone(&self) -> SelectMenuStaticOptions
fn clone(&self) -> SelectMenuStaticOptions
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 SelectMenuStaticOptions
impl Debug for SelectMenuStaticOptions
Source§impl Default for SelectMenuStaticOptions
impl Default for SelectMenuStaticOptions
Source§fn default() -> SelectMenuStaticOptions
fn default() -> SelectMenuStaticOptions
Returns the “default value” for a type. Read more
Source§impl From<SelectMenuStaticOptions> for Accessory
impl From<SelectMenuStaticOptions> for Accessory
Source§fn from(value: SelectMenuStaticOptions) -> Self
fn from(value: SelectMenuStaticOptions) -> Self
Converts to this type from the input type.
Source§impl From<SelectMenuStaticOptions> for ActionsElement
impl From<SelectMenuStaticOptions> for ActionsElement
Source§fn from(value: SelectMenuStaticOptions) -> Self
fn from(value: SelectMenuStaticOptions) -> Self
Converts to this type from the input type.
Source§impl From<SelectMenuStaticOptions> for InputElement
impl From<SelectMenuStaticOptions> for InputElement
Source§fn from(value: SelectMenuStaticOptions) -> Self
fn from(value: SelectMenuStaticOptions) -> Self
Converts to this type from the input type.
Source§impl PartialEq for SelectMenuStaticOptions
impl PartialEq for SelectMenuStaticOptions
Source§impl Serialize for SelectMenuStaticOptions
impl Serialize for SelectMenuStaticOptions
impl StructuralPartialEq for SelectMenuStaticOptions
Auto Trait Implementations§
impl Freeze for SelectMenuStaticOptions
impl RefUnwindSafe for SelectMenuStaticOptions
impl Send for SelectMenuStaticOptions
impl Sync for SelectMenuStaticOptions
impl Unpin for SelectMenuStaticOptions
impl UnwindSafe for SelectMenuStaticOptions
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)