pub struct Container { /* private fields */ }Expand description
Container block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| title | Text<Plain> | Yes | Maximum 150 characters |
| child_blocks | Vec<ContainerChildBlock> | Yes | Maximum 10 items |
| block_id | String | No | Maximum 255 characters |
| width | ContainerWidth | No | N/A |
| subtitle | TextContent | No | Maximum 150 characters |
| icon | elements::Image | No | The alt_text field of the image must be at most 2000 characters |
| is_collapsible | bool | No | N/A |
| default_collapsed | bool | No | N/A |
§Example
The following is reproduction of the sample container block.
use slack_messaging::{plain_text, mrkdwn};
use slack_messaging::blocks::*;
use slack_messaging::blocks::elements::Button;
use slack_messaging::composition_objects::{Plain, Text};
let container = Container::builder()
.block_id("bkb_container_bulk_update")
.title(plain_text!("Bulk update: 2 records selected")?)
.subtitle(plain_text!("Review changes before confirming")?)
.is_collapsible(true)
.child_block(
Section::builder()
.block_id("record-row-1")
.text(mrkdwn!("*DCW-1024*\nStatus: Open → Closed\nAssignee: @princessdonut → @carl")?)
.build()?
)
.child_block(
Divider::builder()
.block_id("bulk-div-1")
.build()?
)
.child_block(
Section::builder()
.block_id("record-row-2")
.text(mrkdwn!("*DCW-1025*\nStatus: In Progress → Closed\nAssignee: @mordecai → @carl")?)
.build()?
)
.child_block(
Divider::builder()
.block_id("bulk-div-2")
.build()?
)
.child_block(
Context::builder()
.block_id("bulk-status-bar")
.element(mrkdwn!(":white_check_mark: 2 records will be updated • Status → Closed • Assignee → @carl")?)
.build()?
)
.child_block(
Actions::builder()
.block_id("bulk-actions")
.element(
Button::builder()
.text(
Text::<Plain>::builder()
.text("Confirm All")
.emoji(true)
.build()?
)
.primary()
.action_id("bulk_confirm")
.build()?
)
.element(
Button::builder()
.text(
Text::<Plain>::builder()
.text("Cancel")
.emoji(true)
.build()?
)
.action_id("bulk_cancel")
.build()?
)
.build()?
)
.build()?;
let expected = serde_json::json!({
"type": "container",
"block_id": "bkb_container_bulk_update",
"title": {
"type": "plain_text",
"text": "Bulk update: 2 records selected"
},
"subtitle": {
"type": "plain_text",
"text": "Review changes before confirming"
},
"is_collapsible": true,
"child_blocks": [
{
"type": "section",
"block_id": "record-row-1",
"text": {
"type": "mrkdwn",
"text": "*DCW-1024*\nStatus: Open → Closed\nAssignee: @princessdonut → @carl"
}
},
{
"type": "divider",
"block_id": "bulk-div-1"
},
{
"type": "section",
"block_id": "record-row-2",
"text": {
"type": "mrkdwn",
"text": "*DCW-1025*\nStatus: In Progress → Closed\nAssignee: @mordecai → @carl"
}
},
{
"type": "divider",
"block_id": "bulk-div-2"
},
{
"type": "context",
"block_id": "bulk-status-bar",
"elements": [
{
"type": "mrkdwn",
"text": ":white_check_mark: 2 records will be updated • Status → Closed • Assignee → @carl"
}
]
},
{
"type": "actions",
"block_id": "bulk-actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Confirm All",
"emoji": true
},
"style": "primary",
"action_id": "bulk_confirm"
},
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Cancel",
"emoji": true
},
"action_id": "bulk_cancel"
}
]
}
]
});
let json = serde_json::to_value(container).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl Container
impl Container
Sourcepub fn builder() -> ContainerBuilder
pub fn builder() -> ContainerBuilder
constract ContainerBuilder object.
Trait Implementations§
impl StructuralPartialEq for Container
Auto Trait Implementations§
impl Freeze for Container
impl RefUnwindSafe for Container
impl Send for Container
impl Sync for Container
impl Unpin for Container
impl UnsafeUnpin for Container
impl UnwindSafe for Container
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more