pub struct IconButton { /* private fields */ }Expand description
Icon button element representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| icon | Icon | Yes | N/A |
| text | Text<Plain> | Yes | N/A |
| action_id | String | No | Max length 255 characters |
| value | String | No | Max length 2000 characters |
| confirm | ConfirmationDialog | No | N/A |
| accessibility_label | String | No | Max length 75 characters |
| visible_to_user_ids | Vec<String> | No | N/A |
§Example
use slack_messaging::plain_text;
use slack_messaging::blocks::elements::{IconButton, types::Icon};
let button = IconButton::builder()
.icon(Icon::Trash)
.text(plain_text!("Delete")?)
.action_id("delete_button")
.value("delete_item")
.build()?;
let expected = serde_json::json!({
"type": "icon_button",
"icon": "trash",
"text": {
"type": "plain_text",
"text": "Delete"
},
"action_id": "delete_button",
"value": "delete_item"
});
let json = serde_json::to_value(button).unwrap();
assert_eq!(json, expected);
// If your object has any validation errors, the build method returns Result::Err
let button = IconButton::builder()
.icon(Icon::Trash)
.build();
assert!(button.is_err());Implementations§
Source§impl IconButton
impl IconButton
Sourcepub fn builder() -> IconButtonBuilder
pub fn builder() -> IconButtonBuilder
constract IconButtonBuilder object.
Trait Implementations§
Source§impl Clone for IconButton
impl Clone for IconButton
Source§fn clone(&self) -> IconButton
fn clone(&self) -> IconButton
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 IconButton
impl Debug for IconButton
Source§impl From<IconButton> for ContextActionsElement
impl From<IconButton> for ContextActionsElement
Source§fn from(value: IconButton) -> Self
fn from(value: IconButton) -> Self
Converts to this type from the input type.
Source§impl PartialEq for IconButton
impl PartialEq for IconButton
Source§impl Serialize for IconButton
impl Serialize for IconButton
impl StructuralPartialEq for IconButton
Auto Trait Implementations§
impl Freeze for IconButton
impl RefUnwindSafe for IconButton
impl Send for IconButton
impl Sync for IconButton
impl Unpin for IconButton
impl UnwindSafe for IconButton
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)