pub struct Section { /* private fields */ }Expand description
Section block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| text | TextContent | Conditionally | Minimum 1 character, Maximum 3000 characters |
| block_id | String | No | Maximum 255 characters |
| fields | Vec<TextContent> | Conditionally | Maximum 10 items, Each item maximum 2000 |
| characters | |||
| accessory | Accessory | No | N/A |
| expand | bool | No | N/A |
§Validation Across Fields
- Either
textorfieldsis required. Both fields cannot be omitted.
§Example
use slack_messaging::{mrkdwn, plain_text};
use slack_messaging::blocks::Section;
use slack_messaging::blocks::elements::Image;
let section = Section::builder()
.block_id("section_1")
.text(mrkdwn!("A message *with some bold text* and _some italicized text_.")?)
.field(mrkdwn!("High")?)
.field(plain_text!("String")?)
.accessory(
Image::builder()
.image_url("http://placekitten.com/700/500")
.alt_text("Multiple cute kittens")
.build()?
)
.build()?;
let expected = serde_json::json!({
"type": "section",
"block_id": "section_1",
"text": {
"type": "mrkdwn",
"text": "A message *with some bold text* and _some italicized text_."
},
"fields": [
{
"type": "mrkdwn",
"text": "High"
},
{
"type": "plain_text",
"text": "String"
}
],
"accessory": {
"type": "image",
"image_url": "http://placekitten.com/700/500",
"alt_text": "Multiple cute kittens"
}
});
let json = serde_json::to_value(section).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl Section
impl Section
Sourcepub fn builder() -> SectionBuilder
pub fn builder() -> SectionBuilder
constract SectionBuilder object.
Trait Implementations§
impl StructuralPartialEq for Section
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnwindSafe for Section
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)