pub struct Button { /* private fields */ }Expand description
Button element representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| text | Text<Plain> | Yes | Max length 75 characters |
| action_id | String | No | Max length 255 characters |
| url | String | No | Max length 3000 characters |
| value | String | No | Max length 2000 characters |
| style | &str | No | Must be either “primary” or “danger” |
| confirm | ConfirmationDialog | No | N/A |
| accessibility_label | String | No | Max length 75 characters |
§Example
use slack_messaging::plain_text;
use slack_messaging::blocks::elements::Button;
let button = Button::builder()
.text(plain_text!("Click Me")?)
.value("click_me_123")
.action_id("button-0")
.build()?;
let expected = serde_json::json!({
"type": "button",
"text": {
"type": "plain_text",
"text": "Click Me"
},
"value": "click_me_123",
"action_id": "button-0"
});
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 = Button::builder()
.value("click_me_123")
.action_id("button-0")
.build();
assert!(button.is_err());Implementations§
Source§impl Button
impl Button
Sourcepub fn builder() -> ButtonBuilder
pub fn builder() -> ButtonBuilder
constract ButtonBuilder object.
Trait Implementations§
Source§impl From<Button> for ActionsElement
impl From<Button> for ActionsElement
impl StructuralPartialEq for Button
Auto Trait Implementations§
impl Freeze for Button
impl RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl UnwindSafe for Button
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)